]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff-merges: introduce '--dd' option
authorSergey Organov <sorganov@gmail.com>
Mon, 9 Oct 2023 16:05:34 +0000 (19:05 +0300)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Oct 2023 19:47:29 +0000 (12:47 -0700)
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>
Documentation/diff-options.txt
Documentation/git-log.txt
diff-merges.c
t/t4013-diff-various.sh

index 4c64eb2ae60589b3f4ebd9a393ec0b0e5d9260e2..ac6bc53d8e9fee8cf82f292af2707258d254f910 100644 (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'.
index 9b7ec96e767ac2a14ac39eacf14abc1859850515..579682172fe45816403f4d5ceffc03949eac5b3a 100644 (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
index ec97616db1dfaa0673945bb08a9f364b2d570db1..45507588a2797b8d3618e3a19a2854d12051157b 100644 (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;
index 5de1d190759f958f8c3c0319f7b4cca34f39d83c..4b474808311e3e654258445128acaacb7b988240 100755 (executable)
@@ -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