Skip to content

Commit

Permalink
diff-merges: introduce '--dd' option
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sorganov authored and gitster committed Oct 9, 2023
1 parent be3820c commit c8e5cb0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Documentation/diff-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/git-log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions diff-merges.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c8e5cb0

Please sign in to comment.