git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/1] merge/pull: extend merge.stat configuration variable to cover --compact-summary
Date: Wed, 11 Jun 2025 10:00:06 -0700	[thread overview]
Message-ID: <xmqqfrg6i57t.fsf@gitster.g> (raw)
In-Reply-To: <xmqq5xh6xlpm.fsf@gitster.g> (Junio C. Hamano's message of "Sun, 08 Jun 2025 09:05:41 -0700")

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 <gitster@pobox.com>
---

 * "git merge --(summary|stat)[=true/false/compact]" is a
   possibility on the command line options side, but options with
   optional values are generally frowned upon, so [1/1] is unchanged
   and introduces a new --compact-summary option.

 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 ce666efbcc..95842188e3 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-207-gc448ca4963


  parent reply	other threads:[~2025-06-11 17:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-08 16:05 [PATCH] merge/pull: --compact-summary Junio C Hamano
2025-06-10 21:16 ` D. Ben Knoble
2025-06-11  3:12   ` Junio C Hamano
2025-06-11 23:26     ` D. Ben Knoble
2025-06-11 17:00 ` Junio C Hamano [this message]
2025-06-11 17:12   ` [PATCH 2/1] merge/pull: extend merge.stat configuration variable to cover --compact-summary Eric Sunshine
2025-06-11 17:29     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqfrg6i57t.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).