mirror of
https://github.com/git/git
synced 2024-09-13 13:24:41 +00:00
rm: reuse strbuf for all remove_dir_recursively() calls, again
Don't throw the memory allocated for remove_dir_recursively() away after a single call, use it for the other entries as well instead. This change was done before indeb8e15a
(rm: reuse strbuf for all remove_dir_recursively() calls), but was reverted as a side-effect of55856a35
(rm: absorb a submodules git dir before deletion). Reinstate the optimization. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3ccd681c2a
commit
590fc05293
|
@ -360,15 +360,14 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
||||||
*/
|
*/
|
||||||
if (!index_only) {
|
if (!index_only) {
|
||||||
int removed = 0, gitmodules_modified = 0;
|
int removed = 0, gitmodules_modified = 0;
|
||||||
|
struct strbuf buf = STRBUF_INIT;
|
||||||
for (i = 0; i < list.nr; i++) {
|
for (i = 0; i < list.nr; i++) {
|
||||||
const char *path = list.entry[i].name;
|
const char *path = list.entry[i].name;
|
||||||
if (list.entry[i].is_submodule) {
|
if (list.entry[i].is_submodule) {
|
||||||
struct strbuf buf = STRBUF_INIT;
|
strbuf_reset(&buf);
|
||||||
|
|
||||||
strbuf_addstr(&buf, path);
|
strbuf_addstr(&buf, path);
|
||||||
if (remove_dir_recursively(&buf, 0))
|
if (remove_dir_recursively(&buf, 0))
|
||||||
die(_("could not remove '%s'"), path);
|
die(_("could not remove '%s'"), path);
|
||||||
strbuf_release(&buf);
|
|
||||||
|
|
||||||
removed = 1;
|
removed = 1;
|
||||||
if (!remove_path_from_gitmodules(path))
|
if (!remove_path_from_gitmodules(path))
|
||||||
|
@ -382,6 +381,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
||||||
if (!removed)
|
if (!removed)
|
||||||
die_errno("git rm: '%s'", path);
|
die_errno("git rm: '%s'", path);
|
||||||
}
|
}
|
||||||
|
strbuf_release(&buf);
|
||||||
if (gitmodules_modified)
|
if (gitmodules_modified)
|
||||||
stage_updated_gitmodules();
|
stage_updated_gitmodules();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue