@matheusbsbs / matheus-bagliano / commits / 12a258c078
Fork 0

reject @{-1} not at beginning of object name

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>

Jeff King committed Jan 28, 2010 at 04:56 UTC 12a258c078da3481a5735a7dca00bbe75cd4713b
2 files changed +5 -1
sha1_name.c
+4
@@ -399,6 +399,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
399 unsigned long co_time;
400 int co_tz, co_cnt;
401
402 + /* a @{-N} placed anywhere except the start is an error */
403 + if (str[at+2] == '-')
404 + return -1;
405 +
406 /* Is it asking for N-th entry, or approxidate? */
407 for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
408 char ch = str[at+2+i];
t/t1508-at-combinations.sh
+1 -1
@@ -45,7 +45,7 @@ check "@{u}" upstream-two
45 check "@{u}@{1}" upstream-one
46 check "@{-1}@{u}" master-two
47 check "@{-1}@{u}@{1}" master-one
48 -fail nonsense "@{u}@{-1}"
48 +nonsense "@{u}@{-1}"
49 nonsense "@{1}@{u}"
50
51 test_done