]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff-merges: let "-m" imply "-p"
authorSergey Organov <sorganov@gmail.com>
Thu, 20 May 2021 21:47:03 +0000 (00:47 +0300)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 May 2021 00:24:14 +0000 (09:24 +0900)
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 <sorganov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/diff-options.txt
diff-merges.c
t/t4013-diff-various.sh

index 6d968b9012dcbe56b616f9edd66b1e869d09e2ae..2825783049c51019bab9d5d20507705d331684cc 100644 (file)
@@ -49,10 +49,9 @@ ifdef::git-log[]
 --diff-merges=m:::
 -m:::
        This option makes diff output for merge commits to be shown in
-       the default format. `-m` will produce the output only if `-p`
-       is given as well. The default format could be changed using
+       the default format. The default format could be changed using
        `log.diffMerges` configuration parameter, which default value
-       is `separate`.
+       is `separate`. `-m` implies `-p`.
 +
 --diff-merges=first-parent:::
 --diff-merges=1:::
@@ -62,7 +61,8 @@ ifdef::git-log[]
 --diff-merges=separate:::
        This makes merge commits show the full diff with respect to
        each of the parents. Separate log entry and diff is generated
-       for each parent.
+       for each parent. This is the format that `-m` produced
+       historically.
 +
 --diff-merges=combined:::
 --diff-merges=c:::
index d897fd8a293319b34172c5c816d28ffb37ad7ce9..0dfcaa1b11b06c456b9b2349859255602df647e8 100644 (file)
@@ -107,6 +107,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv)
 
        if (!strcmp(arg, "-m")) {
                set_to_default(revs);
+               revs->merges_imply_patch = 1;
        } else if (!strcmp(arg, "-c")) {
                set_combined(revs);
                revs->merges_imply_patch = 1;
index e561a8e48521a022ea90891f96d1054cf1ecc68d..7fadc985cccd0558be4e4114434f143605e710a4 100755 (executable)
@@ -455,8 +455,8 @@ diff-tree --stat --compact-summary initial mode
 diff-tree -R --stat --compact-summary initial mode
 EOF
 
-test_expect_success 'log -m matches pure log' '
-       git log master >result &&
+test_expect_success 'log -m matches log -m -p' '
+       git log -m -p master >result &&
        process_diffs result >expected &&
        git log -m >result &&
        process_diffs result >actual &&