diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-06-12 15:25:37 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-06-13 11:54:14 -0700 |
| commit | c8b4805897aa12305389c76480e1d59c4696f2ac (patch) | |
| tree | ab9fcd94043463abc24164dba7954c86f4793868 | |
| parent | merge/pull: add the "--compact-summary" option (diff) | |
| download | git-c8b4805897aa12305389c76480e1d59c4696f2ac.tar.gz git-c8b4805897aa12305389c76480e1d59c4696f2ac.zip | |
merge/pull: extend merge.stat configuration variable to cover --compact-summary
Existing `merge.stat` configuration variable is a Boolean that
defaults to `true` to control `git merge --[no-]stat` behaviour.
Extend it to be "Boolean or text", that takes false, true, or
"compact", with the last one triggering the --compact-summary option
introduced earlier. Any other values are taken as the same as true,
instead of signaling an error---it is not a grave enough offence to
stop their merge.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
| -rw-r--r-- | Documentation/config/merge.adoc | 14 | ||||
| -rw-r--r-- | builtin/merge.c | 31 | ||||
| -rwxr-xr-x | t/t7600-merge.sh | 46 |
3 files changed, 87 insertions, 4 deletions
diff --git a/Documentation/config/merge.adoc b/Documentation/config/merge.adoc index 86359f6dd2..15a4c14c38 100644 --- a/Documentation/config/merge.adoc +++ b/Documentation/config/merge.adoc @@ -81,8 +81,18 @@ as `false`. Defaults to `conflict`. attributes" in linkgit:gitattributes[5]. `merge.stat`:: - Whether to print the diffstat between `ORIG_HEAD` and the merge result - at the end of the merge. True by default. + What, if anything, to print between `ORIG_HEAD` and the merge result + at the end of the merge. Possible values are: ++ +-- +`false`;; Show nothing. +`true`;; Show `git diff --diffstat --summary ORIG_HEAD`. +`compact`;; Show `git diff --compact-summary ORIG_HEAD`. +-- ++ +but any unrecognised value (e.g., a value added by a future version of +Git) is taken as `true` instead of triggering an error. Defaults to +`true`. `merge.autoStash`:: When set to `true`, automatically create a temporary stash entry diff --git a/builtin/merge.c b/builtin/merge.c index 3a6ece14af..18b22c0a26 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -673,8 +673,35 @@ static int git_merge_config(const char *k, const char *v, } if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat")) { - show_diffstat = git_config_bool(k, v) - ? MERGE_SHOW_DIFFSTAT : 0; + int val = git_parse_maybe_bool_text(v); + switch (val) { + case 0: + show_diffstat = 0; + break; + case 1: + show_diffstat = MERGE_SHOW_DIFFSTAT; + break; + default: + if (!strcmp(v, "compact")) + show_diffstat = MERGE_SHOW_COMPACTSUMMARY; + /* + * We do not need to have an explicit + * + * else if (!strcmp(v, "diffstat")) + * show_diffstat = MERGE_SHOW_DIFFSTAT; + * + * here, because the catch-all uses the + * diffstat style anyway. + */ + else + /* + * A setting from a future? It is not an + * error grave enough to fail the command. + * proceed using the default one. + */ + show_diffstat = MERGE_SHOW_DIFFSTAT; + break; + } } else if (!strcmp(k, "merge.verifysignatures")) { verify_signatures = git_config_bool(k, v); } else if (!strcmp(k, "pull.twohead")) { diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 2972922b6a..9838094b66 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -216,6 +216,37 @@ test_expect_success 'merge c0 with c1 with --ff-only' ' verify_head "$c1" ' +test_expect_success 'the same merge with merge.stat=diffstat' ' + cat >expect <<-\EOF && + Updating FROM..TO + Fast-forward + file | 2 +- + other | 9 +++++++++ + 2 files changed, 10 insertions(+), 1 deletion(-) + create mode 100644 other + EOF + + git reset --hard c0 && + git -c merge.stat=diffstat merge c1 >out && + sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual && + test_cmp expect actual +' + +test_expect_success 'the same merge with compact summary' ' + cat >expect <<-\EOF && + Updating FROM..TO + Fast-forward + file | 2 +- + other (new) | 9 +++++++++ + 2 files changed, 10 insertions(+), 1 deletion(-) + EOF + + git reset --hard c0 && + git merge --compact-summary c1 >out && + sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual && + test_cmp expect actual +' + test_expect_success 'the same merge with compact summary' ' cat >expect <<-\EOF && Updating FROM..TO @@ -231,6 +262,21 @@ test_expect_success 'the same merge with compact summary' ' test_cmp expect actual ' +test_expect_success 'the same merge with merge.stat=compact' ' + cat >expect <<-\EOF && + Updating FROM..TO + Fast-forward + file | 2 +- + other (new) | 9 +++++++++ + 2 files changed, 10 insertions(+), 1 deletion(-) + EOF + + git reset --hard c0 && + git -c merge.stat=compact merge c1 >out && + sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual && + test_cmp expect actual +' + test_debug 'git log --graph --decorate --oneline --all' test_expect_success 'merge from unborn branch' ' |
