Skip to content

Commit b285668

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 778e754 commit b285668

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

builtin/fetch-pack.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,17 +1020,16 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
10201020
if (finish_connect(conn))
10211021
return 1;
10221022

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);
10341033
while (ref) {
10351034
printf("%s %s\n",
10361035
sha1_to_hex(ref->old_sha1), ref->name);

0 commit comments

Comments
 (0)