@matheusbsbs / matheus-bagliano / commits / ce4a706388
Fork 0

revision arguments: ..B means HEAD..B, just like A.. means A..HEAD

For consistency reasons, we should probably allow that to be written as just "..branch", the same way we can write "branch.." to mean "everything in HEAD but not in "branch". Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Mar 29, 2006 at 19:41 UTC ce4a706388bd26a3f897bb41a397113f1076ffc6
2 files changed +18 -12
rev-parse.c
+10 -9
@@ -315,16 +315,17 @@ int main(int argc, char **argv)
315 dotdot = strstr(arg, "..");
316 if (dotdot) {
317 unsigned char end[20];
318 - char *n = dotdot+2;
318 + char *next = dotdot + 2;
319 + char *this = arg;
320 *dotdot = 0;
320 - if (!get_sha1(arg, sha1)) {
321 - if (!*n)
322 - n = "HEAD";
323 - if (!get_sha1(n, end)) {
324 - show_rev(NORMAL, end, n);
325 - show_rev(REVERSED, sha1, arg);
326 - continue;
327 - }
321 + if (!*next)
322 + next = "HEAD";
323 + if (dotdot == arg)
324 + this = "HEAD";
325 + if (!get_sha1(this, sha1) && !get_sha1(next, end)) {
326 + show_rev(NORMAL, end, next);
327 + show_rev(REVERSED, sha1, this);
328 + continue;
329 }
330 *dotdot = '.';
331 }
revision.c
+8 -3
@@ -642,14 +642,19 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
642 if (dotdot) {
643 unsigned char from_sha1[20];
644 char *next = dotdot + 2;
645 + char *this = arg;
646 + static const char HEAD[] = "HEAD";
647 *dotdot = 0;
648 if (!*next)
647 - next = "HEAD";
648 - if (!get_sha1(arg, from_sha1) && !get_sha1(next, sha1)) {
649 + next = HEAD;
650 + if (dotdot == arg)
651 + this = HEAD;
652 + if (!get_sha1(this, from_sha1) &&
653 + !get_sha1(next, sha1)) {
654 struct commit *exclude;
655 struct commit *include;
656
652 - exclude = get_commit_reference(revs, arg, from_sha1, flags ^ UNINTERESTING);
657 + exclude = get_commit_reference(revs, this, from_sha1, flags ^ UNINTERESTING);
658 include = get_commit_reference(revs, next, sha1, flags);
659 if (!exclude || !include)
660 die("Invalid revision range %s..%s", arg, next);