]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reject @{-1} not at beginning of object name
authorJeff King <peff@peff.net>
Thu, 28 Jan 2010 09:56:43 +0000 (04:56 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Jan 2010 20:12:50 +0000 (12:12 -0800)
Something like foo@{-1} is nonsensical, as the @{-N} syntax
is reserved for "the Nth last branch", and is not an actual
reflog selector. We should not feed such nonsense to
approxidate at all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
t/t1508-at-combinations.sh

index 00fc4151780a4e66b70a78ac30d4798ad69b976e..77299257bf3aa91079d5b883c6676afa6fd2d01c 100644 (file)
@@ -399,6 +399,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
                unsigned long co_time;
                int co_tz, co_cnt;
 
+               /* a @{-N} placed anywhere except the start is an error */
+               if (str[at+2] == '-')
+                       return -1;
+
                /* Is it asking for N-th entry, or approxidate? */
                for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
                        char ch = str[at+2+i];
index 2a46af24d6ae76dd057a88960a815c53b526d1b8..d5d6244178137cddc985ad4fc32ee3e78c7c5746 100755 (executable)
@@ -45,7 +45,7 @@ check "@{u}" upstream-two
 check "@{u}@{1}" upstream-one
 check "@{-1}@{u}" master-two
 check "@{-1}@{u}@{1}" master-one
-fail nonsense "@{u}@{-1}"
+nonsense "@{u}@{-1}"
 nonsense "@{1}@{u}"
 
 test_done