Merge branch 'jc/dotdot-is-parent-directory'
authorJunio C Hamano <gitster@pobox.com>
Fri, 7 Sep 2012 18:09:18 +0000 (11:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Sep 2012 18:09:18 +0000 (11:09 -0700)
"git log .." errored out saying it is both rev range and a path when
there is no disambiguating "--" is on the command line. Update the
command line parser to interpret ".." as a path in such a case.

* jc/dotdot-is-parent-directory:
specifying ranges: we did not mean to make ".." an empty set

1  2 
builtin/rev-parse.c
revision.c
t/t4202-log.sh
index bb3a5161bb548a676ea0410e8b5b116b6c2e98d6,47b4e7adb956517c22edc580892d63a99d9f219a..f267a1d3b57c1f1ab44c83a197f46051f4f13060
@@@ -241,10 -236,21 +242,21 @@@ static int try_difference(const char *a
        next += symmetric;
  
        if (!*next)
-               next = "HEAD";
+               next = head_by_default;
        if (dotdot == arg)
-               this = "HEAD";
+               this = head_by_default;
+       if (this == head_by_default && next == head_by_default &&
+           !symmetric) {
+               /*
+                * Just ".."?  That is not a range but the
+                * pathspec for the parent directory.
+                */
+               *dotdot = '.';
+               return 0;
+       }
 -      if (!get_sha1(this, sha1) && !get_sha1(next, end)) {
 +      if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
                show_rev(NORMAL, end, next);
                show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
                if (symmetric) {
diff --cc revision.c
index 442a9452334704d90e4457fdeb11014fb886c58a,457868d647378e4b3249f7c3ecae6697bc1ddc04..cbcae1086b346e2b956db7ef9b2729385eaa2ec9
@@@ -1140,11 -1139,22 +1141,22 @@@ int handle_revision_arg(const char *arg
                next += symmetric;
  
                if (!*next)
-                       next = "HEAD";
+                       next = head_by_default;
                if (dotdot == arg)
-                       this = "HEAD";
+                       this = head_by_default;
+               if (this == head_by_default && next == head_by_default &&
+                   !symmetric) {
+                       /*
+                        * Just ".."?  That is not a range but the
+                        * pathspec for the parent directory.
+                        */
+                       if (!cant_be_filename) {
+                               *dotdot = '.';
+                               return -1;
+                       }
+               }
 -              if (!get_sha1(this, from_sha1) &&
 -                  !get_sha1(next, sha1)) {
 +              if (!get_sha1_committish(this, from_sha1) &&
 +                  !get_sha1_committish(next, sha1)) {
                        struct commit *a, *b;
                        struct commit_list *exclude;
  
diff --cc t/t4202-log.sh
index 31869dc0dbcb5f79e4e0f5e307a4d8f617aadbe4,45058cc8cbe038edfb7bb953d9e10067eb5dc4b6..0baaad2a240d401a29b341e1bf01173842a2ab54
@@@ -803,7 -803,14 +803,14 @@@ sanitize_output () 
  test_expect_success 'log --graph with diff and stats' '
        git log --graph --pretty=short --stat -p >actual &&
        sanitize_output >actual.sanitized <actual &&
 -      test_cmp expect actual.sanitized
 +      test_i18ncmp expect actual.sanitized
  '
  
+ test_expect_success 'dotdot is a parent directory' '
+       mkdir -p a/b &&
+       ( echo sixth && echo fifth ) >expect &&
+       ( cd a/b && git log --format=%s .. ) >actual &&
+       test_cmp expect actual
+ '
  test_done