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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -216,6 +216,22 @@ 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
|
||||
@@ -231,6 +247,36 @@ test_expect_success 'the same merge with compact summary' '
|
||||
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 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' '
|
||||
|
||||
Reference in New Issue
Block a user