]> git.ipfire.org Git - thirdparty/git.git/commitdiff
log: enable "-m" automatically with "--first-parent"
authorJeff King <peff@peff.net>
Wed, 29 Jul 2020 20:10:28 +0000 (16:10 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Jul 2020 20:43:57 +0000 (13:43 -0700)
When using "--first-parent" to consider history as a single line of
commits, git-log still defaults to treating merges specially, even
though they could be considered as single commits in the linearized
history (that just introduce all of the changes from the second and
higher parents).

Let's instead have "--first-parent" imply "-m", which makes something
like:

  git log --first-parent -p

do what you'd expect. Likewise:

  git log --first-parent -Sfoo

will find "foo" in merge commits.

No new test is needed; we'll tweak the output of the existing
"--first-parent -p" test, which now matches the "-m --first-parent -p"
test. The unchanged existing test for "--no-diff-merges" confirms that
the user can get the old behavior if they want.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
t/t4013/diff.log_-p_--first-parent_master

index 39b3d773a965574231b5815ca66477872cb3f0d6..83b147c23ad157d8d4718b3a73dc7419e1d4ea54 100644 (file)
@@ -731,6 +731,9 @@ static void log_setup_revisions_tweak(struct rev_info *rev,
        /* Turn --cc/-c into -p --cc/-c when -p was not given */
        if (!rev->diffopt.output_format && rev->combine_merges)
                rev->diffopt.output_format = DIFF_FORMAT_PATCH;
+
+       if (rev->first_parent_only && rev->ignore_merges < 0)
+               rev->ignore_merges = 0;
 }
 
 int cmd_log(int argc, const char **argv, const char *prefix)
index c6a5876d8000b7a1f71fcb927ec08964d0470985..fe044399f04ecc672340b405ae807a976b1c8fb6 100644 (file)
@@ -6,6 +6,28 @@ Date:   Mon Jun 26 00:04:00 2006 +0000
 
     Merge branch 'side' into master
 
+diff --git a/dir/sub b/dir/sub
+index cead32e..992913c 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -4,3 +4,5 @@ C
+ D
+ E
+ F
++1
++2
+diff --git a/file0 b/file0
+index b414108..10a8a9f 100644
+--- a/file0
++++ b/file0
+@@ -4,3 +4,6 @@
+ 4
+ 5
+ 6
++A
++B
++C
+
 commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
 Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:02:00 2006 +0000