Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
rm: reuse strbuf for all remove_dir_recursively() calls
author
René Scharfe
<l.s.r@web.de>
Sat, 9 Jul 2016 14:47:04 +0000
(16:47 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 12 Jul 2016 22:09:21 +0000
(15:09 -0700)
Don't throw the memory allocated for remove_dir_recursively() away after
a single call, use it for the other entries as well instead.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rm.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
50b4a78
)
diff --git
a/builtin/rm.c
b/builtin/rm.c
index 8829b09d0ba5d49edbad5f37f8246123dad3fd5f..7d6787d8dd00963b81bf9e630452c871b70f4e49 100644
(file)
--- a/
builtin/rm.c
+++ b/
builtin/rm.c
@@
-387,6
+387,7
@@
int cmd_rm(int argc, const char **argv, const char *prefix)
*/
if (!index_only) {
int removed = 0, gitmodules_modified = 0;
*/
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) {
for (i = 0; i < list.nr; i++) {
const char *path = list.entry[i].name;
if (list.entry[i].is_submodule) {
@@
-398,7
+399,7
@@
int cmd_rm(int argc, const char **argv, const char *prefix)
continue;
}
} else {
continue;
}
} else {
- str
uct strbuf buf = STRBUF_INIT
;
+ str
buf_reset(&buf)
;
strbuf_addstr(&buf, path);
if (!remove_dir_recursively(&buf, 0)) {
removed = 1;
strbuf_addstr(&buf, path);
if (!remove_dir_recursively(&buf, 0)) {
removed = 1;
@@
-410,7
+411,6
@@
int cmd_rm(int argc, const char **argv, const char *prefix)
/* Submodule was removed by user */
if (!remove_path_from_gitmodules(path))
gitmodules_modified = 1;
/* Submodule was removed by user */
if (!remove_path_from_gitmodules(path))
gitmodules_modified = 1;
- strbuf_release(&buf);
/* Fallthrough and let remove_path() fail. */
}
}
/* Fallthrough and let remove_path() fail. */
}
}
@@
-421,6
+421,7
@@
int cmd_rm(int argc, const char **argv, const char *prefix)
if (!removed)
die_errno("git rm: '%s'", path);
}
if (!removed)
die_errno("git rm: '%s'", path);
}
+ strbuf_release(&buf);
if (gitmodules_modified)
stage_updated_gitmodules();
}
if (gitmodules_modified)
stage_updated_gitmodules();
}