From: Junio C Hamano Date: Wed, 10 Aug 2016 18:55:24 +0000 (-0700) Subject: Merge branch 'rs/rm-strbuf-optim' into maint X-Git-Tag: v2.9.3~18 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b7fb136bf6f49ff7849c8ed8e5d94ca55c210310?hp=-c Merge branch 'rs/rm-strbuf-optim' into maint The use of strbuf in "git rm" to build filename to remove was a bit suboptimal, which has been fixed. * rs/rm-strbuf-optim: rm: reuse strbuf for all remove_dir_recursively() calls --- b7fb136bf6f49ff7849c8ed8e5d94ca55c210310 diff --combined builtin/rm.c index 8abb0207fa,7d6787d8dd..b2fee3e90a --- a/builtin/rm.c +++ b/builtin/rm.c @@@ -152,7 -152,7 +152,7 @@@ static int check_local_mod(unsigned cha if (lstat(ce->name, &st) < 0) { if (errno != ENOENT && errno != ENOTDIR) - warning("'%s': %s", ce->name, strerror(errno)); + warning_errno(_("failed to stat '%s'"), ce->name); /* It already vanished from the working tree */ continue; } @@@ -314,7 -314,7 +314,7 @@@ int cmd_rm(int argc, const char **argv list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode); if (list.entry[list.nr++].is_submodule && !is_staging_gitmodules_ok()) - die (_("Please, stage your changes to .gitmodules or stash them to proceed")); + die (_("Please stage your changes to .gitmodules or stash them to proceed")); } if (pathspec.nr) { @@@ -387,6 -387,7 +387,7 @@@ */ if (!index_only) { int removed = 0, gitmodules_modified = 0; + struct strbuf buf = STRBUF_INIT; for (i = 0; i < list.nr; i++) { const char *path = list.entry[i].name; if (list.entry[i].is_submodule) { @@@ -398,7 -399,7 +399,7 @@@ continue; } } else { - struct strbuf buf = STRBUF_INIT; + strbuf_reset(&buf); strbuf_addstr(&buf, path); if (!remove_dir_recursively(&buf, 0)) { removed = 1; @@@ -410,7 -411,6 +411,6 @@@ /* Submodule was removed by user */ if (!remove_path_from_gitmodules(path)) gitmodules_modified = 1; - strbuf_release(&buf); /* Fallthrough and let remove_path() fail. */ } } @@@ -421,6 -421,7 +421,7 @@@ if (!removed) die_errno("git rm: '%s'", path); } + strbuf_release(&buf); if (gitmodules_modified) stage_updated_gitmodules(); }