Skip to content

Commit 1f27e7d

Browse files
felipecgitster
authored andcommitted
sha1_name: compare variable with constant, not constant with variable
And restructure the if/else to factor out the common "is len positive?" test into a single conditional. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cdfd948 commit 1f27e7d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sha1_name.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,12 +1033,14 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
10331033
int len = interpret_nth_prior_checkout(name, buf);
10341034
int tmp_len;
10351035

1036-
if (!len)
1036+
if (!len) {
10371037
return len; /* syntax Ok, not enough switches */
1038-
if (0 < len && len == namelen)
1039-
return len; /* consumed all */
1040-
else if (0 < len)
1041-
return reinterpret(name, namelen, len, buf);
1038+
} else if (len > 0) {
1039+
if (len == namelen)
1040+
return len; /* consumed all */
1041+
else
1042+
return reinterpret(name, namelen, len, buf);
1043+
}
10421044

10431045
cp = strchr(name, '@');
10441046
if (!cp)

0 commit comments

Comments
 (0)