[PATCH v2 2/2] merge/pull: extend merge.stat configuration variable to cover --compact-summary
From: Junio C Hamano <hidden>
Date: 2025-06-12 22:25:45
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
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. Signed-off-by: Junio C Hamano <redacted> --- Documentation/config/merge.adoc | 12 ++++++++++-- builtin/merge.c | 18 ++++++++++++++++-- t/t7600-merge.sh | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/Documentation/config/merge.adoc b/Documentation/config/merge.adoc
index 86359f6dd2..251a48fdf8 100644
--- a/Documentation/config/merge.adoc
+++ b/Documentation/config/merge.adoc@@ -81,8 +81,16 @@ 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 ORIG_HEAD`. +`compact`;; Show `git diff --compact-summary ORIG_HEAD`. +-- ++ +If this variable is left unspecified, it 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 736739d3a9..65fed4b687 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c@@ -673,8 +673,22 @@ 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; + else + /* setting from the future -- use the default */ + 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..8046c6bb54 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh@@ -231,6 +231,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' '
--
2.50.0-rc2-255-gd84100c98d