Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

"git diff <tree>{3,}": do not reverse order of arguments

According to the message of commit 0fe7c1d,
"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>
  • Loading branch information...
commit b75271d93a9e4be960d53fc4f955802530e0e733 1 parent f285a2d
authored October 10, 2008 spearce committed October 12, 2008
4  builtin-diff.c
@@ -177,10 +177,8 @@ static int builtin_diff_combined(struct rev_info *revs,
177 177
 	if (!revs->dense_combined_merges && !revs->combine_merges)
178 178
 		revs->dense_combined_merges = revs->combine_merges = 1;
179 179
 	parent = xmalloc(ents * sizeof(*parent));
180  
-	/* Again, the revs are all reverse */
181 180
 	for (i = 0; i < ents; i++)
182  
-		hashcpy((unsigned char *)(parent + i),
183  
-			ent[ents - 1 - i].item->sha1);
  181
+		hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
184 182
 	diff_tree_combined(parent[0], parent + 1, ents - 1,
185 183
 			   revs->dense_combined_merges, revs);
186 184
 	return 0;
1  t/t4013-diff-various.sh
@@ -258,6 +258,7 @@ diff --patch-with-stat -r initial..side
258 258
 diff --patch-with-raw -r initial..side
259 259
 diff --name-status dir2 dir
260 260
 diff --no-index --name-status dir2 dir
  261
+diff master master^ side
261 262
 EOF
262 263
 
263 264
 test_done
29  t/t4013/diff.diff_master_master^_side
... ...
@@ -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
+$

0 notes on commit b75271d

Please sign in to comment.
Something went wrong with that request. Please try again.