"git diff <tree>{3,}": do not reverse order of arguments
According to the message of commit 0fe7c1de16f71312e6adac4b85bddf0d62a47168, "git diff" with three or more trees expects the merged tree first followed by the parents, in order. However, this command reversed the order of its arguments, resulting in confusing diffs. A comment /* Again, the revs are all reverse */ suggested there was a reason for this, but I can't figure out the reason, so I removed the reversal of the arguments. Test case included. Signed-off-by: Matt McCutchen <matt@mattmccutchen.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Matt McCutchen committed
Oct 10, 2008 at 21:56 UTC
dbc2fb6b841dd3a72c52a5a161e2362a26fc65f5
3 files changed
+31
-3
builtin-diff.c
+1
-3
@@ -175,10 +175,8 @@ static int builtin_diff_combined(struct rev_info *revs,
175
if (!revs->dense_combined_merges && !revs->combine_merges)
176
revs->dense_combined_merges = revs->combine_merges = 1;
177
parent = xmalloc(ents * sizeof(*parent));
178
- /* Again, the revs are all reverse */
178
for (i = 0; i < ents; i++)
180
- hashcpy((unsigned char *)(parent + i),
181
- ent[ents - 1 - i].item->sha1);
179
+ hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
180
diff_tree_combined(parent[0], parent + 1, ents - 1,
181
revs->dense_combined_merges, revs);
182
return 0;
t/t4013-diff-various.sh
+1
@@ -258,6 +258,7 @@ diff --patch-with-stat -r initial..side
258
diff --patch-with-raw -r initial..side
259
diff --name-status dir2 dir
260
diff --no-index --name-status dir2 dir
261
+diff master master^ side
262
EOF
263
264
test_done
t/t4013/diff.diff_master_master^_side
new
+29
@@ -0,0 +1,29 @@
1
+$ git diff master master^ side
2
+diff --cc dir/sub
3
+index cead32e,7289e35..992913c
4
+--- a/dir/sub
5
++++ b/dir/sub
6
+@@@ -1,6 -1,4 +1,8 @@@
7
+ A
8
+ B
9
+ +C
10
+ +D
11
+ +E
12
+ +F
13
++ 1
14
++ 2
15
+diff --cc file0
16
+index b414108,f4615da..10a8a9f
17
+--- a/file0
18
++++ b/file0
19
+@@@ -1,6 -1,6 +1,9 @@@
20
+ 1
21
+ 2
22
+ 3
23
+ +4
24
+ +5
25
+ +6
26
++ A
27
++ B
28
++ C
29
+$