Skip to content

Commit f9356f9

Browse files
peffgitster
authored andcommitted
fetch: make set_head() call easier to read
We ignore any error returned from set_head(), but 638060d (fetch set_head: refactor to use remote directly, 2025-01-26) left its call in a noop "if" conditional as a sort of note-to-self. When c834d1a (fetch: only respect followRemoteHEAD with configured refspecs, 2025-03-18) added a "do_set_head" flag, it was rolled into the same conditional, putting set_head() on the right-hand side of a short-circuit AND. That's not wrong, but it really hides the point of the line, which is (maybe) calling the function. Instead, let's have a full if() block for the flag, and then our comment (with some rewording) will be sufficient to clarify the error handling. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aab0f89 commit f9356f9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

builtin/fetch.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,12 +1903,13 @@ static int do_fetch(struct transport *transport,
19031903
"you need to specify exactly one branch with the --set-upstream option"));
19041904
}
19051905
}
1906-
if (do_set_head && set_head(remote_refs, transport->remote))
1907-
;
1906+
if (do_set_head) {
19081907
/*
1909-
* Way too many cases where this can go wrong
1910-
* so let's just fail silently for now.
1908+
* Way too many cases where this can go wrong so let's just
1909+
* ignore errors and fail silently for now.
19111910
*/
1911+
set_head(remote_refs, transport->remote);
1912+
}
19121913

19131914
cleanup:
19141915
if (retcode) {

0 commit comments

Comments
 (0)