From: Junio C Hamano Date: Thu, 1 Aug 2013 18:57:25 +0000 (-0700) Subject: Merge branch 'jc/rm-submodule-error-message' X-Git-Tag: v1.8.4-rc1~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/baa2e936990a9bce84fdb8bcffbd940f05800241?ds=inline;hp=-c Merge branch 'jc/rm-submodule-error-message' Consolidate two messages phrased subtly differently without a good reason. * jc/rm-submodule-error-message: builtin/rm.c: consolidate error reporting for removing submodules --- baa2e936990a9bce84fdb8bcffbd940f05800241 diff --combined builtin/rm.c index 18916e022a,694568a0e5..0df0b4d942 --- a/builtin/rm.c +++ b/builtin/rm.c @@@ -51,13 -51,27 +51,28 @@@ static void print_error_files(struct st strbuf_addf(&err_msg, "\n %s", files_list->items[i].string); - strbuf_addstr(&err_msg, hints_msg); + if (advice_rm_hints) + strbuf_addstr(&err_msg, hints_msg); *errs = error("%s", err_msg.buf); strbuf_release(&err_msg); } } + 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; @@@ -67,7 -81,7 +82,7 @@@ for (i = 0; i < list.nr; i++) { const char *name = list.entry[i].name; int pos; - struct cache_entry *ce; + const struct cache_entry *ce; struct stat st; pos = cache_name_pos(name, strlen(name)); @@@ -86,16 -100,8 +101,8 @@@ 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; } @@@ -120,7 -126,7 +127,7 @@@ static int check_local_mod(unsigned cha for (i = 0; i < list.nr; i++) { struct stat st; int pos; - struct cache_entry *ce; + const struct cache_entry *ce; const char *name = list.entry[i].name; unsigned char sha1[20]; unsigned mode; @@@ -237,17 -243,9 +244,9 @@@ " 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:", @@@ -321,7 -319,7 +320,7 @@@ int cmd_rm(int argc, const char **argv seen = xcalloc(i, 1); for (i = 0; i < active_nr; i++) { - struct cache_entry *ce = active_cache[i]; + const struct cache_entry *ce = active_cache[i]; if (!match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen)) continue; ALLOC_GROW(list.entry, list.nr + 1, list.alloc);