summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-12 14:00:34 -0700
committerJunio C Hamano <gitster@pobox.com>2012-09-12 14:00:34 -0700
commiteaff724bbc9c8f838b6d65fff9959da968939c3a (patch)
tree34f4a3cdd4f3a79c5b4f96e3278b234a60386f88 /builtin
parent1b8bc86b5eb86609c31cae48eb7569b24acacc90 (diff)
parent003c84f6d2b9e9c4d5bbf5262cae994bac7190cb (diff)
downloadgit-eaff724bbc9c8f838b6d65fff9959da968939c3a.tar.gz
Merge branch 'jc/dotdot-is-parent-directory' into maint-1.7.11
"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
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rev-parse.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 13495b88f5..47b4e7adb9 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -224,6 +224,7 @@ static int try_difference(const char *arg)
const char *next;
const char *this;
int symmetric;
+ static const char head_by_default[] = "HEAD";
if (!(dotdot = strstr(arg, "..")))
return 0;
@@ -235,9 +236,20 @@ static int try_difference(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.
+ */
+ *dotdot = '.';
+ return 0;
+ }
+
if (!get_sha1(this, sha1) && !get_sha1(next, end)) {
show_rev(NORMAL, end, next);
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);