Skip to content

Commit

Permalink
"git diff <tree>{3,}": do not reverse order of arguments
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Shawn O. Pearce <[email protected]>
  • Loading branch information
mattmccutchen authored and spearce committed Oct 12, 2008
1 parent f285a2d commit b75271d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 1 addition & 3 deletions builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,8 @@ static int builtin_diff_combined(struct rev_info *revs,
if (!revs->dense_combined_merges && !revs->combine_merges)
revs->dense_combined_merges = revs->combine_merges = 1;
parent = xmalloc(ents * sizeof(*parent));
/* Again, the revs are all reverse */
for (i = 0; i < ents; i++)
hashcpy((unsigned char *)(parent + i),
ent[ents - 1 - i].item->sha1);
hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
diff_tree_combined(parent[0], parent + 1, ents - 1,
revs->dense_combined_merges, revs);
return 0;
Expand Down
1 change: 1 addition & 0 deletions t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ diff --patch-with-stat -r initial..side
diff --patch-with-raw -r initial..side
diff --name-status dir2 dir
diff --no-index --name-status dir2 dir
diff master master^ side
EOF

test_done
29 changes: 29 additions & 0 deletions t/t4013/diff.diff_master_master^_side
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$ git diff master master^ side
diff --cc dir/sub
index cead32e,7289e35..992913c
--- a/dir/sub
+++ b/dir/sub
@@@ -1,6 -1,4 +1,8 @@@
A
B
+C
+D
+E
+F
+ 1
+ 2
diff --cc file0
index b414108,f4615da..10a8a9f
--- a/file0
+++ b/file0
@@@ -1,6 -1,6 +1,9 @@@
1
2
3
+4
+5
+6
+ A
+ B
+ C
$

0 comments on commit b75271d

Please sign in to comment.