show --first-parent/-m: do not default to --cc
Given that "git show" always shows some diff and does not walk the history by default, it is natural to expect "git show --first-parent" to show the difference between the given commit and its first parent. It also would be natural, given that "--cc" is the default, "git show -m" to show pairwise difference from each of the parents. We however always defaulted to --cc and there was no way to turn it off. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 9, 2010 at 00:22 UTC
2bf6587349e31b582dae47954b1a334052230e28
4 files changed
+134
-3
builtin-log.c
+9
-3
@@ -329,6 +329,15 @@ static int show_tree_object(const unsigned char *sha1,
329
330
static void show_rev_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt)
331
{
332
+ if (rev->ignore_merges) {
333
+ /* There was no "-m" on the command line */
334
+ rev->ignore_merges = 0;
335
+ if (!rev->first_parent_only && !rev->combine_merges) {
336
+ /* No "--first-parent", "-c", nor "--cc" */
337
+ rev->combine_merges = 1;
338
+ rev->dense_combined_merges = 1;
339
+ }
340
+ }
341
if (!rev->diffopt.output_format)
342
rev->diffopt.output_format = DIFF_FORMAT_PATCH;
343
}
@@ -347,10 +356,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
356
357
init_revisions(&rev, prefix);
358
rev.diff = 1;
350
- rev.combine_merges = 1;
351
- rev.dense_combined_merges = 1;
359
rev.always_show_header = 1;
353
- rev.ignore_merges = 0;
360
rev.no_walk = 1;
361
memset(&opt, 0, sizeof(opt));
362
opt.def = "HEAD";
t/t4013-diff-various.sh
+2
@@ -239,6 +239,8 @@ show --root initial
239
show side
240
show master
241
show -c master
242
+show -m master
243
+show --first-parent master
244
show --stat side
245
show --stat --summary side
246
show --patch-with-stat side
t/t4013/diff.show_--first-parent_master
new
+30
@@ -0,0 +1,30 @@
1
+$ git show --first-parent master
2
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64
3
+Merge: 9a6d494 c7a2ab9
4
+Author: A U Thor <author@example.com>
5
+Date: Mon Jun 26 00:04:00 2006 +0000
6
+
7
+ Merge branch 'side'
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
+$
t/t4013/diff.show_-m_master
new
+93
@@ -0,0 +1,93 @@
1
+$ git show -m master
2
+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0)
3
+Merge: 9a6d494 c7a2ab9
4
+Author: A U Thor <author@example.com>
5
+Date: Mon Jun 26 00:04:00 2006 +0000
6
+
7
+ Merge branch 'side'
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 59d314ad6f356dd08601a4cd5e530381da3e3c64 (from c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a)
32
+Merge: 9a6d494 c7a2ab9
33
+Author: A U Thor <author@example.com>
34
+Date: Mon Jun 26 00:04:00 2006 +0000
35
+
36
+ Merge branch 'side'
37
+
38
+diff --git a/dir/sub b/dir/sub
39
+index 7289e35..992913c 100644
40
+--- a/dir/sub
41
++++ b/dir/sub
42
+@@ -1,4 +1,8 @@
43
+ A
44
+ B
45
++C
46
++D
47
++E
48
++F
49
+ 1
50
+ 2
51
+diff --git a/file0 b/file0
52
+index f4615da..10a8a9f 100644
53
+--- a/file0
54
++++ b/file0
55
+@@ -1,6 +1,9 @@
56
+ 1
57
+ 2
58
+ 3
59
++4
60
++5
61
++6
62
+ A
63
+ B
64
+ C
65
+diff --git a/file1 b/file1
66
+new file mode 100644
67
+index 0000000..b1e6722
68
+--- /dev/null
69
++++ b/file1
70
+@@ -0,0 +1,3 @@
71
++A
72
++B
73
++C
74
+diff --git a/file2 b/file2
75
+deleted file mode 100644
76
+index 01e79c3..0000000
77
+--- a/file2
78
++++ /dev/null
79
+@@ -1,3 +0,0 @@
80
+-1
81
+-2
82
+-3
83
+diff --git a/file3 b/file3
84
+deleted file mode 100644
85
+index 7289e35..0000000
86
+--- a/file3
87
++++ /dev/null
88
+@@ -1,4 +0,0 @@
89
+-A
90
+-B
91
+-1
92
+-2
93
+$