Skip to content

Commit

Permalink
cmd_fetch_pack(): simplify computation of return value
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Sep 12, 2012
1 parent 778e754 commit b285668
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b285668

Please sign in to comment.