Skip to content

Commit a555b51

Browse files
committed
Merge branch 'so/log-diff-merges-opt'
Earlier, to countermand the implicit "-m" option when the "--first-parent" option is used with "git log", we added the "--[no-]diff-merges" option in the jk/log-fp-implies-m topic. To leave the door open to allow the "--diff-merges" option to take values that instructs how patches for merge commits should be computed (e.g. "cc"? "-p against first parent?"), redefine "--diff-merges" to take non-optional value, and implement "off" that means the same thing as "--no-diff-merges". * so/log-diff-merges-opt: t/t4013: add test for --diff-merges=off doc/git-log: describe --diff-merges=off revision: change "--diff-merges" option to require parameter
2 parents eca8c62 + 298889d commit a555b51

File tree

5 files changed

+171
-2
lines changed

5 files changed

+171
-2
lines changed

Documentation/git-log.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,18 @@ combined-diff option or with `--no-diff-merges`).
148148
rename or copy detection have been requested).
149149

150150
-m::
151-
--diff-merges::
152151
This flag makes the merge commits show the full diff like
153152
regular commits; for each merge parent, a separate log entry
154153
and diff is generated. An exception is that only diff against
155154
the first parent is shown when `--first-parent` option is given;
156155
in that case, the output represents the changes the merge
157156
brought _into_ the then-current branch.
158157

158+
--diff-merges=off::
159+
--no-diff-merges::
160+
Disable output of diffs for merge commits (default). Useful to
161+
override `-m`, `-c`, or `--cc`.
162+
159163
:git-log: 1
160164
include::diff-options.txt[]
161165

revision.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,8 +2343,15 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
23432343
revs->diff = 1;
23442344
revs->diffopt.flags.recursive = 1;
23452345
revs->diffopt.flags.tree_in_recursive = 1;
2346-
} else if (!strcmp(arg, "-m") || !strcmp(arg, "--diff-merges")) {
2346+
} else if (!strcmp(arg, "-m")) {
23472347
revs->ignore_merges = 0;
2348+
} else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
2349+
if (!strcmp(optarg, "off")) {
2350+
revs->ignore_merges = 1;
2351+
} else {
2352+
die(_("unknown value for --diff-merges: %s"), optarg);
2353+
}
2354+
return argcount;
23482355
} else if (!strcmp(arg, "--no-diff-merges")) {
23492356
revs->ignore_merges = 1;
23502357
} else if (!strcmp(arg, "-c")) {

t/t4013-diff-various.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ log --root -c --patch-with-stat --summary master
298298
# improved by Timo's patch
299299
log --root --cc --patch-with-stat --summary master
300300
log --no-diff-merges -p --first-parent master
301+
log --diff-merges=off -p --first-parent master
302+
log --first-parent --diff-merges=off -p master
301303
log -p --first-parent master
302304
log -m -p --first-parent master
303305
log -m -p master
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
$ git log --diff-merges=off -p --first-parent master
2+
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
3+
Merge: 9a6d494 c7a2ab9
4+
Author: A U Thor <[email protected]>
5+
Date: Mon Jun 26 00:04:00 2006 +0000
6+
7+
Merge branch 'side'
8+
9+
commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
10+
Author: A U Thor <[email protected]>
11+
Date: Mon Jun 26 00:02:00 2006 +0000
12+
13+
Third
14+
15+
diff --git a/dir/sub b/dir/sub
16+
index 8422d40..cead32e 100644
17+
--- a/dir/sub
18+
+++ b/dir/sub
19+
@@ -2,3 +2,5 @@ A
20+
B
21+
C
22+
D
23+
+E
24+
+F
25+
diff --git a/file1 b/file1
26+
new file mode 100644
27+
index 0000000..b1e6722
28+
--- /dev/null
29+
+++ b/file1
30+
@@ -0,0 +1,3 @@
31+
+A
32+
+B
33+
+C
34+
35+
commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
36+
Author: A U Thor <[email protected]>
37+
Date: Mon Jun 26 00:01:00 2006 +0000
38+
39+
Second
40+
41+
This is the second commit.
42+
43+
diff --git a/dir/sub b/dir/sub
44+
index 35d242b..8422d40 100644
45+
--- a/dir/sub
46+
+++ b/dir/sub
47+
@@ -1,2 +1,4 @@
48+
A
49+
B
50+
+C
51+
+D
52+
diff --git a/file0 b/file0
53+
index 01e79c3..b414108 100644
54+
--- a/file0
55+
+++ b/file0
56+
@@ -1,3 +1,6 @@
57+
1
58+
2
59+
3
60+
+4
61+
+5
62+
+6
63+
diff --git a/file2 b/file2
64+
deleted file mode 100644
65+
index 01e79c3..0000000
66+
--- a/file2
67+
+++ /dev/null
68+
@@ -1,3 +0,0 @@
69+
-1
70+
-2
71+
-3
72+
73+
commit 444ac553ac7612cc88969031b02b3767fb8a353a
74+
Author: A U Thor <[email protected]>
75+
Date: Mon Jun 26 00:00:00 2006 +0000
76+
77+
Initial
78+
$
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
$ git log --first-parent --diff-merges=off -p master
2+
commit 80e25ffa65bcdbe82ef654b4d06dbbde7945c37f
3+
Merge: 9a6d494 c7a2ab9
4+
Author: A U Thor <[email protected]>
5+
Date: Mon Jun 26 00:04:00 2006 +0000
6+
7+
Merge branch 'side'
8+
9+
commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
10+
Author: A U Thor <[email protected]>
11+
Date: Mon Jun 26 00:02:00 2006 +0000
12+
13+
Third
14+
15+
diff --git a/dir/sub b/dir/sub
16+
index 8422d40..cead32e 100644
17+
--- a/dir/sub
18+
+++ b/dir/sub
19+
@@ -2,3 +2,5 @@ A
20+
B
21+
C
22+
D
23+
+E
24+
+F
25+
diff --git a/file1 b/file1
26+
new file mode 100644
27+
index 0000000..b1e6722
28+
--- /dev/null
29+
+++ b/file1
30+
@@ -0,0 +1,3 @@
31+
+A
32+
+B
33+
+C
34+
35+
commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44
36+
Author: A U Thor <[email protected]>
37+
Date: Mon Jun 26 00:01:00 2006 +0000
38+
39+
Second
40+
41+
This is the second commit.
42+
43+
diff --git a/dir/sub b/dir/sub
44+
index 35d242b..8422d40 100644
45+
--- a/dir/sub
46+
+++ b/dir/sub
47+
@@ -1,2 +1,4 @@
48+
A
49+
B
50+
+C
51+
+D
52+
diff --git a/file0 b/file0
53+
index 01e79c3..b414108 100644
54+
--- a/file0
55+
+++ b/file0
56+
@@ -1,3 +1,6 @@
57+
1
58+
2
59+
3
60+
+4
61+
+5
62+
+6
63+
diff --git a/file2 b/file2
64+
deleted file mode 100644
65+
index 01e79c3..0000000
66+
--- a/file2
67+
+++ /dev/null
68+
@@ -1,3 +0,0 @@
69+
-1
70+
-2
71+
-3
72+
73+
commit 444ac553ac7612cc88969031b02b3767fb8a353a
74+
Author: A U Thor <[email protected]>
75+
Date: Mon Jun 26 00:00:00 2006 +0000
76+
77+
Initial
78+
$

0 commit comments

Comments
 (0)