builtin/mv duplicate string list memory
makes the next patch easier, where we will migrate to the paths being owned by a strvec. given that we are talking about command line parameters here it's also not like we have tons of allocations that this would save while at it, fix a memory leak Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
3d231f7b82
commit
9fcd9e4e72
19
builtin/mv.c
19
builtin/mv.c
|
@ -183,11 +183,12 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
||||||
struct strbuf a_src_dir = STRBUF_INIT;
|
struct strbuf a_src_dir = STRBUF_INIT;
|
||||||
enum update_mode *modes, dst_mode = 0;
|
enum update_mode *modes, dst_mode = 0;
|
||||||
struct stat st, dest_st;
|
struct stat st, dest_st;
|
||||||
struct string_list src_for_dst = STRING_LIST_INIT_NODUP;
|
struct string_list src_for_dst = STRING_LIST_INIT_DUP;
|
||||||
struct lock_file lock_file = LOCK_INIT;
|
struct lock_file lock_file = LOCK_INIT;
|
||||||
struct cache_entry *ce;
|
struct cache_entry *ce;
|
||||||
struct string_list only_match_skip_worktree = STRING_LIST_INIT_NODUP;
|
struct string_list only_match_skip_worktree = STRING_LIST_INIT_DUP;
|
||||||
struct string_list dirty_paths = STRING_LIST_INIT_NODUP;
|
struct string_list dirty_paths = STRING_LIST_INIT_DUP;
|
||||||
|
int ret;
|
||||||
|
|
||||||
git_config(git_default_config, NULL);
|
git_config(git_default_config, NULL);
|
||||||
|
|
||||||
|
@ -440,8 +441,10 @@ remove_entry:
|
||||||
|
|
||||||
if (only_match_skip_worktree.nr) {
|
if (only_match_skip_worktree.nr) {
|
||||||
advise_on_updating_sparse_paths(&only_match_skip_worktree);
|
advise_on_updating_sparse_paths(&only_match_skip_worktree);
|
||||||
if (!ignore_errors)
|
if (!ignore_errors) {
|
||||||
return 1;
|
ret = 1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
|
@ -566,12 +569,16 @@ remove_entry:
|
||||||
COMMIT_LOCK | SKIP_IF_UNCHANGED))
|
COMMIT_LOCK | SKIP_IF_UNCHANGED))
|
||||||
die(_("Unable to write new index file"));
|
die(_("Unable to write new index file"));
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
free(dst_w_slash);
|
free(dst_w_slash);
|
||||||
string_list_clear(&src_for_dst, 0);
|
string_list_clear(&src_for_dst, 0);
|
||||||
string_list_clear(&dirty_paths, 0);
|
string_list_clear(&dirty_paths, 0);
|
||||||
|
string_list_clear(&only_match_skip_worktree, 0);
|
||||||
UNLEAK(source);
|
UNLEAK(source);
|
||||||
UNLEAK(dest_path);
|
UNLEAK(dest_path);
|
||||||
free(submodule_gitfile);
|
free(submodule_gitfile);
|
||||||
free(modes);
|
free(modes);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue