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>
This commit is contained in:
Michael Haggerty 2012-09-09 08:19:48 +02:00 committed by Junio C Hamano
parent 778e7543d2
commit b285668dd2

View File

@ -1020,17 +1020,16 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
if (finish_connect(conn)) if (finish_connect(conn))
return 1; return 1;
ret = !ref; ret = !ref || sought.nr;
if (sought.nr) {
/* If the heads to pull were given, we should have /*
* consumed all of them by matching the remote. * If the heads to pull were given, we should have consumed
* Otherwise, 'git fetch remote no-such-ref' would * all of them by matching the remote. Otherwise, 'git fetch
* silently succeed without issuing an error. * 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); for (i = 0; i < sought.nr; i++)
ret = 1; error("no such remote ref %s", sought.items[i].string);
}
while (ref) { while (ref) {
printf("%s %s\n", printf("%s %s\n",
sha1_to_hex(ref->old_sha1), ref->name); sha1_to_hex(ref->old_sha1), ref->name);