@matheusbsbs / matheus-bagliano / commits / 9ab89a2439
Fork 0

log: enable "-m" automatically with "--first-parent"

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>

Jeff King committed Jul 29, 2020 at 16:10 UTC 9ab89a2439064720cc790c4477b8e981832c43f5
2 files changed +25
builtin/log.c
+3
@@ -731,6 +731,9 @@ static void log_setup_revisions_tweak(struct rev_info *rev,
731 /* Turn --cc/-c into -p --cc/-c when -p was not given */
732 if (!rev->diffopt.output_format && rev->combine_merges)
733 rev->diffopt.output_format = DIFF_FORMAT_PATCH;
734 +
735 + if (rev->first_parent_only && rev->ignore_merges < 0)
736 + rev->ignore_merges = 0;
737 }
738
739 int cmd_log(int argc, const char **argv, const char *prefix)
t/t4013/diff.log_-p_--first-parent_master
+22
@@ -6,6 +6,28 @@ Date: Mon Jun 26 00:04:00 2006 +0000
6
7 Merge branch 'side' into master
8
9 +diff --git a/dir/sub b/dir/sub
10 +index cead32e..992913c 100644
11 +--- a/dir/sub
12 ++++ b/dir/sub
13 +@@ -4,3 +4,5 @@ C
14 + D
15 + E
16 + F
17 ++1
18 ++2
19 +diff --git a/file0 b/file0
20 +index b414108..10a8a9f 100644
21 +--- a/file0
22 ++++ b/file0
23 +@@ -4,3 +4,6 @@
24 + 4
25 + 5
26 + 6
27 ++A
28 ++B
29 ++C
30 +
31 commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
32 Author: A U Thor <author@example.com>
33 Date: Mon Jun 26 00:02:00 2006 +0000