diff-merges: introduce '--dd' option

This option provides a shortcut to request diff with respect to first
parent for any kind of commit, universally. It's implemented as pure
synonym for "--diff-merges=first-parent --patch".

Gives user quick and universal way to see what changes, exactly, were
brought to a branch by merges as well as by regular commits.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Sergey Organov 2023-10-09 19:05:34 +03:00 committed by Junio C Hamano
parent be3820c60c
commit c8e5cb0658
4 changed files with 17 additions and 1 deletions

View File

@ -50,6 +50,11 @@ ifdef::git-log[]
Produce dense combined diff output for merge commits.
Shortcut for '--diff-merges=dense-combined -p'.
--dd::
Produce diff with respect to first parent for both merge and
regular commits.
Shortcut for '--diff-merges=first-parent -p'.
--remerge-diff::
Produce remerge-diff output for merge commits.
Shortcut for '--diff-merges=remerge -p'.

View File

@ -120,7 +120,7 @@ By default, `git log` does not generate any diff output. The options
below can be used to show the changes made by each commit.
Note that unless one of `--diff-merges` variants (including short
`-m`, `-c`, and `--cc` options) is explicitly given, merge commits
`-m`, `-c`, `--cc`, and `--dd` options) is explicitly given, merge commits
will not show a diff, even if a diff format like `--patch` is
selected, nor will they match search options like `-S`. The exception
is when `--first-parent` is in use, in which case `first-parent` is

View File

@ -131,6 +131,9 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
} else if (!strcmp(arg, "--cc")) {
set_dense_combined(revs);
revs->merges_imply_patch = 1;
} else if (!strcmp(arg, "--dd")) {
set_first_parent(revs);
revs->merges_imply_patch = 1;
} else if (!strcmp(arg, "--remerge-diff")) {
set_remerge_diff(revs);
revs->merges_imply_patch = 1;

View File

@ -473,6 +473,14 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' '
test_cmp expected actual
'
test_expect_success 'log --dd matches --diff-merges=1 -p' '
git log --diff-merges=1 -p master >result &&
process_diffs result >expected &&
git log --dd master >result &&
process_diffs result >actual &&
test_cmp expected actual
'
test_expect_success 'deny wrong log.diffMerges config' '
test_config log.diffMerges wrong-value &&
test_expect_code 128 git log