fetch: make set_head() call easier to read

We ignore any error returned from set_head(), but 638060dcb9 (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 c834d1a7ce (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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Apr 4, 2025 at 04:58 UTC f9356f9cb4c2c9c6baab30c1a8579445fddfe502
1 file changed +5 -4
builtin/fetch.c
+5 -4
@@ -1903,12 +1903,13 @@ static int do_fetch(struct transport *transport,
1903 "you need to specify exactly one branch with the --set-upstream option"));
1904 }
1905 }
1906 - if (do_set_head && set_head(remote_refs, transport->remote))
1907 - ;
1906 + if (do_set_head) {
1907 /*
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.
1910 */
1911 + set_head(remote_refs, transport->remote);
1912 + }
1913
1914 cleanup:
1915 if (retcode) {