Skip to content

Commit c8e5cb0

Browse files
sorganovgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent be3820c commit c8e5cb0

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Documentation/diff-options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ ifdef::git-log[]
5050
Produce dense combined diff output for merge commits.
5151
Shortcut for '--diff-merges=dense-combined -p'.
5252

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+
5358
--remerge-diff::
5459
Produce remerge-diff output for merge commits.
5560
Shortcut for '--diff-merges=remerge -p'.

Documentation/git-log.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ By default, `git log` does not generate any diff output. The options
120120
below can be used to show the changes made by each commit.
121121

122122
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
124124
will not show a diff, even if a diff format like `--patch` is
125125
selected, nor will they match search options like `-S`. The exception
126126
is when `--first-parent` is in use, in which case `first-parent` is

diff-merges.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
131131
} else if (!strcmp(arg, "--cc")) {
132132
set_dense_combined(revs);
133133
revs->merges_imply_patch = 1;
134+
} else if (!strcmp(arg, "--dd")) {
135+
set_first_parent(revs);
136+
revs->merges_imply_patch = 1;
134137
} else if (!strcmp(arg, "--remerge-diff")) {
135138
set_remerge_diff(revs);
136139
revs->merges_imply_patch = 1;

t/t4013-diff-various.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' '
473473
test_cmp expected actual
474474
'
475475

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+
476484
test_expect_success 'deny wrong log.diffMerges config' '
477485
test_config log.diffMerges wrong-value &&
478486
test_expect_code 128 git log

0 commit comments

Comments
 (0)