From: Ramkumar Ramachandra <artagnon@xxxxxxxxx> It's trivial to check for them in the @{N} parsing loop. [fc: style] Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> --- sha1_name.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index c512c69..db965af 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -448,7 +448,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) if (len && str[len-1] == '}') { for (at = len-4; at >= 0; at--) { if (str[at] == '@' && str[at+1] == '{') { - if (at == 0 && str[2] == '-') { + if (str[at+2] == '-') { + if (at != 0) + /* @{-N} not at start */ + return -1; nth_prior = 1; continue; } @@ -497,10 +500,6 @@ 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]; -- 1.8.3.rc0.401.g45bba44 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html