aboutsummaryrefslogtreecommitdiff
path: root/builtin/rm.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-07-25 23:05:17 -0700
committerJunio C Hamano <gitster@pobox.com>2013-07-25 23:05:17 -0700
commit658ff473cf35217253aa956508ff0e42993711ad (patch)
treea46a6132123f8172c59d1519a7b86f64cc449dcf /builtin/rm.c
parent914dc0289d1df75cfa744cea8ec84cb529cbc791 (diff)
downloadgit-658ff473cf35217253aa956508ff0e42993711ad.tar.gz
git-658ff473cf35217253aa956508ff0e42993711ad.tar.xz
builtin/rm.c: consolidate error reporting for removing submodules
We have two (not identical) copies of error reporting when attempting to remove submodules that have their repositories embedded within them. Add a helper function so that we do not have to repeat similar error messages with subtly different wording without a good reason. Noticed by Jiang Xin. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rm.c')
-rw-r--r--builtin/rm.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/builtin/rm.c b/builtin/rm.c
index 5d0c0683d..694568a0e 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -57,6 +57,21 @@ static void print_error_files(struct string_list *files_list,
}
}
+static void error_removing_concrete_submodules(struct string_list *files, int *errs)
+{
+ print_error_files(files,
+ Q_("the following submodule (or one of its nested "
+ "submodules)\n"
+ "uses a .git directory:",
+ "the following submodules (or one of its nested "
+ "submodules)\n"
+ "use a .git directory:", files->nr),
+ _("\n(use 'rm -rf' if you really want to remove "
+ "it including all of its history)"),
+ errs);
+ string_list_clear(files, 0);
+}
+
static int check_submodules_use_gitfiles(void)
{
int i;
@@ -85,16 +100,8 @@ static int check_submodules_use_gitfiles(void)
if (!submodule_uses_gitfile(name))
string_list_append(&files, name);
}
- print_error_files(&files,
- Q_("the following submodule (or one of its nested "
- "submodules)\n uses a .git directory:",
- "the following submodules (or one of its nested "
- "submodules)\n use a .git directory:",
- files.nr),
- _("\n(use 'rm -rf' if you really want to remove "
- "it including all of its history)"),
- &errs);
- string_list_clear(&files, 0);
+
+ error_removing_concrete_submodules(&files, &errs);
return errs;
}
@@ -236,17 +243,9 @@ static int check_local_mod(unsigned char *head, int index_only)
" or -f to force removal)"),
&errs);
string_list_clear(&files_cached, 0);
- print_error_files(&files_submodule,
- Q_("the following submodule (or one of its nested "
- "submodule)\nuses a .git directory:",
- "the following submodules (or one of its nested "
- "submodule)\nuse a .git directory:",
- files_submodule.nr),
- _("\n(use 'rm -rf' if you really "
- "want to remove it including all "
- "of its history)"),
- &errs);
- string_list_clear(&files_submodule, 0);
+
+ error_removing_concrete_submodules(&files_submodule, &errs);
+
print_error_files(&files_local,
Q_("the following file has local modifications:",
"the following files have local modifications:",