Skip to content

Commit f5bfcc8

Browse files
sorganovgitster
authored andcommitted
diff-merges: let "-m" imply "-p"
Fix long standing inconsistency between -c/--cc that do imply -p on one side, and -m that did not imply -p on the other side. Change corresponding test accordingly, as "log -m" output should now match one from "log -m -p", rather than from just "log". Change documentation accordingly. NOTES: After this patch git log -m produces diffs without need to provide -p as well, that improves both consistency and usability. It gets even more useful if one sets "log.diffMerges" configuration variable to "first-parent" to force -m produce usual diff with respect to first parent only. This patch, however, does not change behavior when specific diff format is explicitly provided on the command-line, so that commands like git log -m --raw git log -m --stat are not affected, nor does it change commands where specific diff format is active by default, such as: git diff-tree -m It's also worth to be noticed that exact historical semantics of -m is still provided by --diff-merges=separate. Signed-off-by: Sergey Organov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd16a39 commit f5bfcc8

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Documentation/diff-options.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ ifdef::git-log[]
4949
--diff-merges=m:::
5050
-m:::
5151
This option makes diff output for merge commits to be shown in
52-
the default format. `-m` will produce the output only if `-p`
53-
is given as well. The default format could be changed using
52+
the default format. The default format could be changed using
5453
`log.diffMerges` configuration parameter, which default value
55-
is `separate`.
54+
is `separate`. `-m` implies `-p`.
5655
+
5756
--diff-merges=first-parent:::
5857
--diff-merges=1:::
@@ -62,7 +61,8 @@ ifdef::git-log[]
6261
--diff-merges=separate:::
6362
This makes merge commits show the full diff with respect to
6463
each of the parents. Separate log entry and diff is generated
65-
for each parent.
64+
for each parent. This is the format that `-m` produced
65+
historically.
6666
+
6767
--diff-merges=combined:::
6868
--diff-merges=c:::

diff-merges.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
107107

108108
if (!strcmp(arg, "-m")) {
109109
set_to_default(revs);
110+
revs->merges_imply_patch = 1;
110111
} else if (!strcmp(arg, "-c")) {
111112
set_combined(revs);
112113
revs->merges_imply_patch = 1;

t/t4013-diff-various.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ diff-tree --stat --compact-summary initial mode
455455
diff-tree -R --stat --compact-summary initial mode
456456
EOF
457457

458-
test_expect_success 'log -m matches pure log' '
459-
git log master >result &&
458+
test_expect_success 'log -m matches log -m -p' '
459+
git log -m -p master >result &&
460460
process_diffs result >expected &&
461461
git log -m >result &&
462462
process_diffs result >actual &&

0 commit comments

Comments
 (0)