summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-04-30 16:49:11 -0500
committerJunio C Hamano <gitster@pobox.com>2013-05-08 12:13:12 -0700
commit1f27e7d56b65fdc232a5a2a4de2ee97ff5eb176b (patch)
tree01ad40cd6ed0dbb41bdcbcfe0eacb182ffa1b9ff /sha1_name.c
parentcdfd94837b27c220f70f032b596ea993d195488f (diff)
downloadgit-1f27e7d56b65fdc232a5a2a4de2ee97ff5eb176b.tar.gz
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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 4428df19a7..5a58720d85 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -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)