diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-05-11 11:38:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-11 11:38:36 -0700 |
commit | c7fe5b61e15cc5195e33f7d5e5ec452e6966c1ad (patch) | |
tree | bc8b989475dcb5abacff4135df4bc7aa8de43461 /builtin/merge.c | |
parent | Merge branch 'jn/maint-test-merge-verify-parents' (diff) | |
parent | merge: make branch.<name>.mergeoptions correctly override merge.<option> (diff) | |
download | tgif-c7fe5b61e15cc5195e33f7d5e5ec452e6966c1ad.tar.xz |
Merge branch 'jc/maint-branch-mergeoptions'
* jc/maint-branch-mergeoptions:
merge: make branch.<name>.mergeoptions correctly override merge.<option>
Conflicts:
builtin/merge.c
Diffstat (limited to 'builtin/merge.c')
-rw-r--r-- | builtin/merge.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index d171c63c52..9661c8f425 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -56,6 +56,7 @@ static size_t use_strategies_nr, use_strategies_alloc; static const char **xopts; static size_t xopts_nr, xopts_alloc; static const char *branch; +static char *branch_mergeoptions; static int option_renormalize; static int verbosity; static int allow_rerere_auto; @@ -503,26 +504,34 @@ cleanup: strbuf_release(&bname); } +static void parse_branch_merge_options(char *bmo) +{ + const char **argv; + int argc; + + if (!bmo) + return; + argc = split_cmdline(bmo, &argv); + if (argc < 0) + die(_("Bad branch.%s.mergeoptions string: %s"), branch, + split_cmdline_strerror(argc)); + argv = xrealloc(argv, sizeof(*argv) * (argc + 2)); + memmove(argv + 1, argv, sizeof(*argv) * (argc + 1)); + argc++; + argv[0] = "branch.*.mergeoptions"; + parse_options(argc, argv, NULL, builtin_merge_options, + builtin_merge_usage, 0); + free(argv); +} + static int git_merge_config(const char *k, const char *v, void *cb) { if (branch && !prefixcmp(k, "branch.") && !prefixcmp(k + 7, branch) && !strcmp(k + 7 + strlen(branch), ".mergeoptions")) { - const char **argv; - int argc; - char *buf; - - buf = xstrdup(v); - argc = split_cmdline(buf, &argv); - if (argc < 0) - die(_("Bad branch.%s.mergeoptions string: %s"), branch, - split_cmdline_strerror(argc)); - argv = xrealloc(argv, sizeof(*argv) * (argc + 2)); - memmove(argv + 1, argv, sizeof(*argv) * (argc + 1)); - argc++; - parse_options(argc, argv, NULL, builtin_merge_options, - builtin_merge_usage, 0); - free(buf); + free(branch_mergeoptions); + branch_mergeoptions = xstrdup(v); + return 0; } if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat")) @@ -1010,6 +1019,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (diff_use_color_default == -1) diff_use_color_default = git_use_color_default; + if (branch_mergeoptions) + parse_branch_merge_options(branch_mergeoptions); argc = parse_options(argc, argv, prefix, builtin_merge_options, builtin_merge_usage, 0); |