mirror of
https://github.com/git/git
synced 2024-11-05 01:58:18 +00:00
builtin/merge: always store allocated strings in pull_twohead
The `pull_twohead` configuration may sometimes contain an allocated string, and sometimes it may contain a string constant. Refactor this to instead always store an allocated string such that we can release its resources without risk. While at it, manage the lifetime of other config strings, as well. Note that we explicitly don't free `cleanup_arg` here. This is because the variable may be assigned a string constant via command line options. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fc06676766
commit
71e01a0ebd
1 changed files with 11 additions and 7 deletions
|
@ -611,17 +611,19 @@ static int git_merge_config(const char *k, const char *v,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
|
||||
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat")) {
|
||||
show_diffstat = git_config_bool(k, v);
|
||||
else if (!strcmp(k, "merge.verifysignatures"))
|
||||
} else if (!strcmp(k, "merge.verifysignatures")) {
|
||||
verify_signatures = git_config_bool(k, v);
|
||||
else if (!strcmp(k, "pull.twohead"))
|
||||
} else if (!strcmp(k, "pull.twohead")) {
|
||||
FREE_AND_NULL(pull_twohead);
|
||||
return git_config_string(&pull_twohead, k, v);
|
||||
else if (!strcmp(k, "pull.octopus"))
|
||||
} else if (!strcmp(k, "pull.octopus")) {
|
||||
FREE_AND_NULL(pull_octopus);
|
||||
return git_config_string(&pull_octopus, k, v);
|
||||
else if (!strcmp(k, "commit.cleanup"))
|
||||
} else if (!strcmp(k, "commit.cleanup")) {
|
||||
return git_config_string(&cleanup_arg, k, v);
|
||||
else if (!strcmp(k, "merge.ff")) {
|
||||
} else if (!strcmp(k, "merge.ff")) {
|
||||
int boolval = git_parse_maybe_bool(v);
|
||||
if (0 <= boolval) {
|
||||
fast_forward = boolval ? FF_ALLOW : FF_NO;
|
||||
|
@ -1294,7 +1296,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||
if (!pull_twohead) {
|
||||
char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
|
||||
if (default_strategy && !strcmp(default_strategy, "ort"))
|
||||
pull_twohead = "ort";
|
||||
pull_twohead = xstrdup("ort");
|
||||
}
|
||||
|
||||
init_diff_ui_defaults();
|
||||
|
@ -1793,6 +1795,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||
}
|
||||
strbuf_release(&buf);
|
||||
free(branch_to_free);
|
||||
free(pull_twohead);
|
||||
free(pull_octopus);
|
||||
discard_index(the_repository->index);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue