Skip to content

Commit

Permalink
sha1_name: compare variable with constant, not constant with variable
Browse files Browse the repository at this point in the history
And restructure the if/else to factor out the common "is len positive?"
test into a single conditional.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed May 8, 2013
1 parent cdfd948 commit 1f27e7d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,12 +1033,14 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
int len = interpret_nth_prior_checkout(name, buf);
int tmp_len;

if (!len)
if (!len) {
return len; /* syntax Ok, not enough switches */
if (0 < len && len == namelen)
return len; /* consumed all */
else if (0 < len)
return reinterpret(name, namelen, len, buf);
} else if (len > 0) {
if (len == namelen)
return len; /* consumed all */
else
return reinterpret(name, namelen, len, buf);
}

cp = strchr(name, '@');
if (!cp)
Expand Down

0 comments on commit 1f27e7d

Please sign in to comment.