summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-09-09 06:19:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-12 18:46:32 (GMT)
commitb285668dd23952b96d716aac769c0ed1080d11d3 (patch)
tree9a0b2b72e93540750bb3940fd9114822aa20234e /builtin
parent778e7543d20531bec93d5c9965f32541e78b8e34 (diff)
downloadgit-b285668dd23952b96d716aac769c0ed1080d11d3.zip
git-b285668dd23952b96d716aac769c0ed1080d11d3.tar.gz
git-b285668dd23952b96d716aac769c0ed1080d11d3.tar.bz2
cmd_fetch_pack(): simplify computation of return value
Set the final value at initialization rather than initializing it then sometimes changing it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch-pack.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 3d388b5..42078e5 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -1020,17 +1020,16 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
if (finish_connect(conn))
return 1;
- ret = !ref;
- if (sought.nr) {
- /* If the heads to pull were given, we should have
- * consumed all of them by matching the remote.
- * Otherwise, 'git fetch remote no-such-ref' would
- * silently succeed without issuing an error.
- */
- for (i = 0; i < sought.nr; i++)
- error("no such remote ref %s", sought.items[i].string);
- ret = 1;
- }
+ ret = !ref || sought.nr;
+
+ /*
+ * If the heads to pull were given, we should have consumed
+ * all of them by matching the remote. Otherwise, 'git fetch
+ * remote no-such-ref' would silently succeed without issuing
+ * an error.
+ */
+ for (i = 0; i < sought.nr; i++)
+ error("no such remote ref %s", sought.items[i].string);
while (ref) {
printf("%s %s\n",
sha1_to_hex(ref->old_sha1), ref->name);