Skip to content

Commit 4fc5ff2

Browse files
committed
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. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea9692d commit 4fc5ff2

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

Documentation/config/merge.adoc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ as `false`. Defaults to `conflict`.
8181
attributes" in linkgit:gitattributes[5].
8282

8383
`merge.stat`::
84-
Whether to print the diffstat between `ORIG_HEAD` and the merge result
85-
at the end of the merge. True by default.
84+
What, if anything, to print between `ORIG_HEAD` and the merge result
85+
at the end of the merge. Possible values are:
86+
+
87+
--
88+
`false`;; Show nothing.
89+
`true`;; Show `git diff --diffstat ORIG_HEAD`.
90+
`compact`;; Show `git diff --compact-summary ORIG_HEAD`.
91+
--
92+
+
93+
If this variable is left unspecified, it defaults to `true`.
8694

8795
`merge.autoStash`::
8896
When set to `true`, automatically create a temporary stash entry

builtin/merge.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,22 @@ static int git_merge_config(const char *k, const char *v,
673673
}
674674

675675
if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat")) {
676-
show_diffstat = git_config_bool(k, v)
677-
? MERGE_SHOW_DIFFSTAT : 0;
676+
int val = git_parse_maybe_bool_text(v);
677+
switch (val) {
678+
case 0:
679+
show_diffstat = 0;
680+
break;
681+
case 1:
682+
show_diffstat = MERGE_SHOW_DIFFSTAT;
683+
break;
684+
default:
685+
if (!strcmp(v, "compact"))
686+
show_diffstat = MERGE_SHOW_COMPACTSUMMARY;
687+
else
688+
/* setting from the future -- use the default */
689+
show_diffstat = MERGE_SHOW_DIFFSTAT;
690+
break;
691+
}
678692
} else if (!strcmp(k, "merge.verifysignatures")) {
679693
verify_signatures = git_config_bool(k, v);
680694
} else if (!strcmp(k, "pull.twohead")) {

t/t7600-merge.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,21 @@ test_expect_success 'the same merge with compact summary' '
231231
test_cmp expect actual
232232
'
233233

234+
test_expect_success 'the same merge with merge.stat=compact' '
235+
cat >expect <<-\EOF &&
236+
Updating FROM..TO
237+
Fast-forward
238+
file | 2 +-
239+
other (new) | 9 +++++++++
240+
2 files changed, 10 insertions(+), 1 deletion(-)
241+
EOF
242+
243+
git reset --hard c0 &&
244+
git -c merge.stat=compact merge c1 >out &&
245+
sed -e "1s/^Updating [0-9a-f.]*/Updating FROM..TO/" out >actual &&
246+
test_cmp expect actual
247+
'
248+
234249
test_debug 'git log --graph --decorate --oneline --all'
235250

236251
test_expect_success 'merge from unborn branch' '

0 commit comments

Comments
 (0)