Skip to content

Commit 755fb09

Browse files
committed
Merge branch 'so/diff-merges-dd'
"git log" and friends learned "--dd" that is a short-hand for "--diff-merges=first-parent -p". * so/diff-merges-dd: completion: complete '--dd' diff-merges: introduce '--dd' option diff-merges: improve --diff-merges documentation
2 parents f32af12 + 7c446ac commit 755fb09

File tree

5 files changed

+73
-49
lines changed

5 files changed

+73
-49
lines changed

Documentation/diff-options.txt

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,66 +37,79 @@ endif::git-diff[]
3737
endif::git-format-patch[]
3838

3939
ifdef::git-log[]
40-
--diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc|remerge|r)::
40+
-m::
41+
Show diffs for merge commits in the default format. This is
42+
similar to '--diff-merges=on', except `-m` will
43+
produce no output unless `-p` is given as well.
44+
45+
-c::
46+
Produce combined diff output for merge commits.
47+
Shortcut for '--diff-merges=combined -p'.
48+
49+
--cc::
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'.
61+
4162
--no-diff-merges::
63+
Synonym for '--diff-merges=off'.
64+
65+
--diff-merges=<format>::
4266
Specify diff format to be used for merge commits. Default is
43-
{diff-merges-default} unless `--first-parent` is in use, in which case
44-
`first-parent` is the default.
67+
{diff-merges-default} unless `--first-parent` is in use, in
68+
which case `first-parent` is the default.
4569
+
46-
--diff-merges=(off|none):::
47-
--no-diff-merges:::
70+
The following formats are supported:
71+
+
72+
--
73+
off, none::
4874
Disable output of diffs for merge commits. Useful to override
4975
implied value.
5076
+
51-
--diff-merges=on:::
52-
--diff-merges=m:::
53-
-m:::
54-
This option makes diff output for merge commits to be shown in
55-
the default format. `-m` will produce the output only if `-p`
56-
is given as well. The default format could be changed using
57-
`log.diffMerges` configuration parameter, which default value
77+
on, m::
78+
Make diff output for merge commits to be shown in the default
79+
format. The default format could be changed using
80+
`log.diffMerges` configuration variable, whose default value
5881
is `separate`.
5982
+
60-
--diff-merges=first-parent:::
61-
--diff-merges=1:::
62-
This option makes merge commits show the full diff with
63-
respect to the first parent only.
83+
first-parent, 1::
84+
Show full diff with respect to first parent. This is the same
85+
format as `--patch` produces for non-merge commits.
86+
+
87+
separate::
88+
Show full diff with respect to each of parents.
89+
Separate log entry and diff is generated for each parent.
6490
+
65-
--diff-merges=separate:::
66-
This makes merge commits show the full diff with respect to
67-
each of the parents. Separate log entry and diff is generated
68-
for each parent.
91+
combined, c::
92+
Show differences from each of the parents to the merge
93+
result simultaneously instead of showing pairwise diff between
94+
a parent and the result one at a time. Furthermore, it lists
95+
only files which were modified from all parents.
6996
+
70-
--diff-merges=remerge:::
71-
--diff-merges=r:::
72-
--remerge-diff:::
73-
With this option, two-parent merge commits are remerged to
74-
create a temporary tree object -- potentially containing files
75-
with conflict markers and such. A diff is then shown between
76-
that temporary tree and the actual merge commit.
97+
dense-combined, cc::
98+
Further compress output produced by `--diff-merges=combined`
99+
by omitting uninteresting hunks whose contents in the parents
100+
have only two variants and the merge result picks one of them
101+
without modification.
102+
+
103+
remerge, r::
104+
Remerge two-parent merge commits to create a temporary tree
105+
object--potentially containing files with conflict markers
106+
and such. A diff is then shown between that temporary tree
107+
and the actual merge commit.
77108
+
78109
The output emitted when this option is used is subject to change, and
79110
so is its interaction with other options (unless explicitly
80111
documented).
81-
+
82-
--diff-merges=combined:::
83-
--diff-merges=c:::
84-
-c:::
85-
With this option, diff output for a merge commit shows the
86-
differences from each of the parents to the merge result
87-
simultaneously instead of showing pairwise diff between a
88-
parent and the result one at a time. Furthermore, it lists
89-
only files which were modified from all parents. `-c` implies
90-
`-p`.
91-
+
92-
--diff-merges=dense-combined:::
93-
--diff-merges=cc:::
94-
--cc:::
95-
With this option the output produced by
96-
`--diff-merges=combined` is further compressed by omitting
97-
uninteresting hunks whose contents in the parents have only
98-
two variants and the merge result picks one of them without
99-
modification. `--cc` implies `-p`.
112+
--
100113

101114
--combined-all-paths::
102115
This flag causes combined diffs (used for merge commits) to

Documentation/git-log.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ 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
127-
the default format.
127+
the default format for merge commits.
128128

129129
:git-log: 1
130130
:diff-merges-default: `off`

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ __git_log_shortlog_options="
20532053
"
20542054
# Options accepted by log and show
20552055
__git_log_show_options="
2056-
--diff-merges --diff-merges= --no-diff-merges --remerge-diff
2056+
--diff-merges --diff-merges= --no-diff-merges --dd --remerge-diff
20572057
"
20582058

20592059
__git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-combined cc remerge r"

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)