aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-04-04 04:58:12 -0400
committerJunio C Hamano <gitster@pobox.com>2025-04-09 09:03:47 -0700
commitf9356f9cb4c2c9c6baab30c1a8579445fddfe502 (patch)
treeef7cb42343765c0021787efd27f7307f1440ad9b /builtin/fetch.c
parentfetch: don't ask for remote HEAD if followRemoteHEAD is "never" (diff)
downloadgit-f9356f9cb4c2c9c6baab30c1a8579445fddfe502.tar.gz
git-f9356f9cb4c2c9c6baab30c1a8579445fddfe502.zip
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>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 3658509740..dbf741ef5b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1903,12 +1903,13 @@ static int do_fetch(struct transport *transport,
"you need to specify exactly one branch with the --set-upstream option"));
}
}
- if (do_set_head && set_head(remote_refs, transport->remote))
- ;
+ if (do_set_head) {
/*
- * Way too many cases where this can go wrong
- * so let's just fail silently for now.
+ * Way too many cases where this can go wrong so let's just
+ * ignore errors and fail silently for now.
*/
+ set_head(remote_refs, transport->remote);
+ }
cleanup:
if (retcode) {