mirror of
https://github.com/git/git.git
synced 2026-08-08 17:11:48 +00:00
Merge branch 'tc/merge-default-to-upstream-leakfix'
A memory leak in 'git merge' when run without arguments (which triggers the default-to-upstream path) has been fixed. A test has been added to cover this case. * tc/merge-default-to-upstream-leakfix: merge: fix leak with merge.defaultToUpstream
This commit is contained in:
@@ -1373,7 +1373,7 @@ int cmd_merge(int argc,
|
||||
struct commit_list *common = NULL;
|
||||
const char *best_strategy = NULL, *wt_strategy = NULL;
|
||||
struct commit_list *remoteheads = NULL, *p;
|
||||
void *branch_to_free;
|
||||
void *branch_to_free, *argv_to_free = NULL;
|
||||
int orig_argc = argc;
|
||||
int merge_log_config = -1;
|
||||
|
||||
@@ -1517,8 +1517,10 @@ int cmd_merge(int argc,
|
||||
option_commit = 1;
|
||||
|
||||
if (!argc) {
|
||||
if (default_to_upstream)
|
||||
if (default_to_upstream) {
|
||||
argc = setup_with_upstream(&argv);
|
||||
argv_to_free = argv;
|
||||
}
|
||||
else
|
||||
die(_("No commit specified and merge.defaultToUpstream not set."));
|
||||
} else if (argc == 1 && !strcmp(argv[0], "-")) {
|
||||
@@ -1880,6 +1882,7 @@ done:
|
||||
}
|
||||
strbuf_release(&buf);
|
||||
free(branch_to_free);
|
||||
free(argv_to_free);
|
||||
free(pull_twohead);
|
||||
free(pull_octopus);
|
||||
discard_index(the_repository->index);
|
||||
|
||||
@@ -1166,4 +1166,21 @@ test_expect_success 'suggested names are not ambiguous' '
|
||||
test_grep remotes/origin/not-local stderr
|
||||
'
|
||||
|
||||
test_expect_success 'merge with no argument defaults to upstream' '
|
||||
test_when_finished "rm -rf upstream downstream" &&
|
||||
git init upstream &&
|
||||
(
|
||||
cd upstream &&
|
||||
test_commit one &&
|
||||
test_commit two
|
||||
) &&
|
||||
git clone upstream downstream &&
|
||||
(
|
||||
cd downstream &&
|
||||
git reset --hard HEAD^ &&
|
||||
git merge &&
|
||||
test_cmp_rev origin/main HEAD
|
||||
)
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user