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>
Michael Haggerty committed
Sep 9, 2012 at 08:19 UTC
b285668dd23952b96d716aac769c0ed1080d11d3
1 file changed
+10
-11
builtin/fetch-pack.c
+10
-11
@@ -1020,17 +1020,16 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
1020
if (finish_connect(conn))
1021
return 1;
1022
1023
- ret = !ref;
1024
- if (sought.nr) {
1025
- /* If the heads to pull were given, we should have
1026
- * consumed all of them by matching the remote.
1027
- * Otherwise, 'git fetch remote no-such-ref' would
1028
- * silently succeed without issuing an error.
1029
- */
1030
- for (i = 0; i < sought.nr; i++)
1031
- error("no such remote ref %s", sought.items[i].string);
1032
- ret = 1;
1033
- }
1023
+ ret = !ref || sought.nr;
1024
+
1025
+ /*
1026
+ * If the heads to pull were given, we should have consumed
1027
+ * all of them by matching the remote. Otherwise, 'git fetch
1028
+ * remote no-such-ref' would silently succeed without issuing
1029
+ * an error.
1030
+ */
1031
+ for (i = 0; i < sought.nr; i++)
1032
+ error("no such remote ref %s", sought.items[i].string);
1033
while (ref) {
1034
printf("%s %s\n",
1035
sha1_to_hex(ref->old_sha1), ref->name);