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>

Sergey Organov committed Oct 9, 2023 at 19:05 UTC c8e5cb065802e96c5aa5dd25936d9780c5734182
4 files changed +17 -1
Documentation/diff-options.txt
+5
@@ -50,6 +50,11 @@ ifdef::git-log[]
50 Produce dense combined diff output for merge commits.
51 Shortcut for '--diff-merges=dense-combined -p'.
52
53 +--dd::
54 + Produce diff with respect to first parent for both merge and
55 + regular commits.
56 + Shortcut for '--diff-merges=first-parent -p'.
57 +
58 --remerge-diff::
59 Produce remerge-diff output for merge commits.
60 Shortcut for '--diff-merges=remerge -p'.
Documentation/git-log.txt
+1 -1
@@ -120,7 +120,7 @@ By default, `git log` does not generate any diff output. The options
120 below can be used to show the changes made by each commit.
121
122 Note that unless one of `--diff-merges` variants (including short
123 -`-m`, `-c`, and `--cc` options) is explicitly given, merge commits
123 +`-m`, `-c`, `--cc`, and `--dd` options) is explicitly given, merge commits
124 will not show a diff, even if a diff format like `--patch` is
125 selected, nor will they match search options like `-S`. The exception
126 is when `--first-parent` is in use, in which case `first-parent` is
diff-merges.c
+3
@@ -131,6 +131,9 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
131 } else if (!strcmp(arg, "--cc")) {
132 set_dense_combined(revs);
133 revs->merges_imply_patch = 1;
134 + } else if (!strcmp(arg, "--dd")) {
135 + set_first_parent(revs);
136 + revs->merges_imply_patch = 1;
137 } else if (!strcmp(arg, "--remerge-diff")) {
138 set_remerge_diff(revs);
139 revs->merges_imply_patch = 1;
t/t4013-diff-various.sh
+8
@@ -473,6 +473,14 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' '
473 test_cmp expected actual
474 '
475
476 +test_expect_success 'log --dd matches --diff-merges=1 -p' '
477 + git log --diff-merges=1 -p master >result &&
478 + process_diffs result >expected &&
479 + git log --dd master >result &&
480 + process_diffs result >actual &&
481 + test_cmp expected actual
482 +'
483 +
484 test_expect_success 'deny wrong log.diffMerges config' '
485 test_config log.diffMerges wrong-value &&
486 test_expect_code 128 git log