From: Ramkumar Ramachandra Date: Thu, 02 May 2013 19:47:58 GMT Subject: Re: [PATCH v2] sha1_name: reorganize get_sha1_basic() Message-ID: <1367524078-13266-1-git-send-email-artagnon@gmail.com> In-Reply-To: A small suggestion. Squash this in if you like; optionally submit it as a separate part. diff --git a/sha1_name.c b/sha1_name.c index 6428001..109ab41 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -448,11 +448,12 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) if (len && str[len-1] == '}') { for (at = len-2; at >= 0; at--) { if (str[at] == '@' && str[at+1] == '{') { - if (at == 0 && str[2] == '-') { - nth_prior = 1; - continue; - } - if (!upstream_mark(str + at, len - at)) { + if (str[at+2] == '-') { + if (at != 0) + return -1; + else + nth_prior = 1; + } else if (!upstream_mark(str + at, len - at)) { reflog_len = (len-1) - (at+2); len = at; } @@ -497,10 +498,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];