diff options
| -rw-r--r-- | builtin/fetch.c | 6 | ||||
| -rwxr-xr-x | t/t5510-fetch.sh | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index 66f5ae31b6..3658509740 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1643,9 +1643,6 @@ static int set_head(const struct ref *remote_refs, struct remote *remote) string_list_append(&heads, strip_refshead(ref->name)); } - if (follow_remote_head == FOLLOW_REMOTE_NEVER) - goto cleanup; - if (!heads.nr) result = 1; else if (heads.nr > 1) @@ -1729,7 +1726,8 @@ static int do_fetch(struct transport *transport, if (transport->remote->fetch.nr) { refspec_ref_prefixes(&transport->remote->fetch, &transport_ls_refs_options.ref_prefixes); - do_set_head = 1; + if (transport->remote->follow_remote_head != FOLLOW_REMOTE_NEVER) + do_set_head = 1; } if (branch_has_merge_config(branch) && !strcmp(branch->remote_name, transport->remote->name)) { diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index ad23dd11ef..5f0eb5684e 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -119,7 +119,10 @@ test_expect_success "fetch test followRemoteHEAD never" ' cd two && git update-ref --no-deref -d refs/remotes/origin/HEAD && git config set remote.origin.followRemoteHEAD "never" && - git fetch && + GIT_TRACE_PACKET=$PWD/trace.out git fetch && + # Confirm that we do not even ask for HEAD when we are + # not going to act on it. + test_grep ! "ref-prefix HEAD" trace.out && test_must_fail git rev-parse --verify refs/remotes/origin/HEAD ) ' |
