aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-02-16 14:45:13 -0800
committerJunio C Hamano <gitster@pobox.com>2017-02-16 14:45:13 -0800
commit1e00c41fd69a94be423cf5278e75da594c23eb9d (patch)
treeb7cbd9b91e3426bd50764d858e13cc3e1bd49a7e /builtin
parenta3b3c9c916298199e4a80afccc2e14b69e5d6d42 (diff)
parent590fc05293964160e4360431950325658d75fe23 (diff)
downloadgit-1e00c41fd69a94be423cf5278e75da594c23eb9d.tar.gz
git-1e00c41fd69a94be423cf5278e75da594c23eb9d.tar.xz
Merge branch 'rs/strbuf-cleanup-in-rmdir-recursively'
Code clean-up. * rs/strbuf-cleanup-in-rmdir-recursively: rm: reuse strbuf for all remove_dir_recursively() calls, again
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/rm.c b/builtin/rm.c
index 452170a3a..fb79dcab1 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -360,15 +360,14 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
*/
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) {
- struct strbuf buf = STRBUF_INIT;
-
+ strbuf_reset(&buf);
strbuf_addstr(&buf, path);
if (remove_dir_recursively(&buf, 0))
die(_("could not remove '%s'"), path);
- strbuf_release(&buf);
removed = 1;
if (!remove_path_from_gitmodules(path))
@@ -382,6 +381,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
if (!removed)
die_errno("git rm: '%s'", path);
}
+ strbuf_release(&buf);
if (gitmodules_modified)
stage_updated_gitmodules();
}