Skip to content

Commit 1e00c41

Browse files
committed
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
2 parents a3b3c9c + 590fc05 commit 1e00c41

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/rm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,14 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
360360
*/
361361
if (!index_only) {
362362
int removed = 0, gitmodules_modified = 0;
363+
struct strbuf buf = STRBUF_INIT;
363364
for (i = 0; i < list.nr; i++) {
364365
const char *path = list.entry[i].name;
365366
if (list.entry[i].is_submodule) {
366-
struct strbuf buf = STRBUF_INIT;
367-
367+
strbuf_reset(&buf);
368368
strbuf_addstr(&buf, path);
369369
if (remove_dir_recursively(&buf, 0))
370370
die(_("could not remove '%s'"), path);
371-
strbuf_release(&buf);
372371

373372
removed = 1;
374373
if (!remove_path_from_gitmodules(path))
@@ -382,6 +381,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
382381
if (!removed)
383382
die_errno("git rm: '%s'", path);
384383
}
384+
strbuf_release(&buf);
385385
if (gitmodules_modified)
386386
stage_updated_gitmodules();
387387
}

0 commit comments

Comments
 (0)