aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-04-17 10:28:17 -0700
committerJunio C Hamano <gitster@pobox.com>2025-04-17 10:28:17 -0700
commitb45113f5818b26bf22b85988f9ef7ff2da06d4a1 (patch)
treec7fa852ecfd618919e8888eaa2c3c0d314f2fbd8 /t
parentThe sixth batch (diff)
parentfetch: make set_head() call easier to read (diff)
downloadgit-b45113f5818b26bf22b85988f9ef7ff2da06d4a1.tar.gz
git-b45113f5818b26bf22b85988f9ef7ff2da06d4a1.zip
Merge branch 'jk/fetch-follow-remote-head-fix'
"git fetch [<remote>]" with only the configured fetch refspec should be the only thing to update refs/remotes/<remote>/HEAD, but the code was overly eager to do so in other cases. * jk/fetch-follow-remote-head-fix: fetch: make set_head() call easier to read fetch: don't ask for remote HEAD if followRemoteHEAD is "never" fetch: only respect followRemoteHEAD with configured refspecs
Diffstat (limited to 't')
-rwxr-xr-xt/t5505-remote.sh2
-rwxr-xr-xt/t5510-fetch.sh19
2 files changed, 19 insertions, 2 deletions
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 82fccf8e36..bef0250e89 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -499,7 +499,7 @@ test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
cd test &&
git fetch two "refs/heads/*:refs/remotes/two/*" &&
git remote set-head --auto two >output 2>&1 &&
- echo "${SQ}two/HEAD${SQ} is unchanged and points to ${SQ}main${SQ}" >expect &&
+ echo "${SQ}two/HEAD${SQ} is now created and points to ${SQ}main${SQ}" >expect &&
test_cmp expect output
)
'
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 7a7818006e..ebc696546b 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -125,7 +125,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
)
'
@@ -256,6 +259,20 @@ test_expect_success "fetch test followRemoteHEAD always" '
)
'
+test_expect_success 'followRemoteHEAD does not kick in with refspecs' '
+ test_when_finished "git config unset remote.origin.followRemoteHEAD" &&
+ (
+ cd "$D" &&
+ cd two &&
+ git remote set-head origin other &&
+ git config set remote.origin.followRemoteHEAD always &&
+ git fetch origin refs/heads/main:refs/remotes/origin/main &&
+ echo refs/remotes/origin/other >expect &&
+ git symbolic-ref refs/remotes/origin/HEAD >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'fetch --prune on its own works as expected' '
cd "$D" &&
git clone . prune &&