mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'rs/rm-strbuf-optim'
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
This commit is contained in:
commit
03f25e85d9
|
@ -387,6 +387,7 @@ 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) {
|
||||||
|
@ -398,7 +399,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
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)) {
|
||||||
removed = 1;
|
removed = 1;
|
||||||
|
@ -410,7 +411,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
|
||||||
/* Submodule was removed by user */
|
/* Submodule was removed by user */
|
||||||
if (!remove_path_from_gitmodules(path))
|
if (!remove_path_from_gitmodules(path))
|
||||||
gitmodules_modified = 1;
|
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)
|
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