git-diff A...B to (usually) mean "git-diff `git-merge-base A B` B"
This tweaks the argument parser of "git diff" to allow "git-diff A...B" to show diffs leading to B since their merge-base, when there is only one sensible merge base between A and B. Currently nonsense cases are thrown at combined-diff to produce nonsense results, which would eventually need to be fixed. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jul 17, 2006 at 00:34 UTC
9919f41c91e525fd813fd2cd006f8fdcf976a661
1 file changed
+9
-1
builtin-diff.c
+9
-1
@@ -346,7 +346,15 @@ int cmd_diff(int argc, const char **argv, char **envp)
346
return builtin_diff_index(&rev, argc, argv);
347
else if (ents == 2)
348
return builtin_diff_tree(&rev, argc, argv, ent);
349
+ else if ((ents == 3) && (ent[0].item->flags & UNINTERESTING)) {
350
+ /* diff A...B where there is one sane merge base between
351
+ * A and B. We have ent[0] == merge-base, ent[1] == A,
352
+ * and ent[2] == B. Show diff between the base and B.
353
+ */
354
+ return builtin_diff_tree(&rev, argc, argv, ent);
355
+ }
356
else
350
- return builtin_diff_combined(&rev, argc, argv, ent, ents);
357
+ return builtin_diff_combined(&rev, argc, argv,
358
+ ent, ents);
359
usage(builtin_diff_usage);
360
}