3 test_description
='test fetching of oddly-named refs'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
10 # afterwards we will have:
12 # refs/for/refs/heads/main - one
13 # refs/heads/main - three
14 test_expect_success
'setup repo with odd suffix ref' '
18 git update-ref refs/for/refs/heads/main HEAD &&
19 echo content >>file &&
20 git commit -a -m two &&
21 echo content >>file &&
22 git commit -a -m three &&
26 test_expect_success
'suffix ref is ignored during fetch' '
27 git clone --bare file://"$PWD" suffix &&
29 git --git-dir=suffix log -1 --format=%s refs/heads/main >actual &&
30 test_cmp expect actual
33 test_expect_success
'try to create repo with absurdly long refname' '
34 ref240=$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID &&
35 ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 &&
42 if git -C long update-ref refs/heads/$ref1440 long; then
43 test_set_prereq LONG_REF
45 echo >&2 "long refs not supported"
49 test_expect_success LONG_REF
'fetch handles extremely long refname' '
50 git fetch long refs/heads/*:refs/remotes/long/* &&
51 cat >expect <<-\EOF &&
55 git for-each-ref --format="%(subject)" refs/remotes/long >actual &&
56 test_cmp expect actual
59 test_expect_success LONG_REF
'push handles extremely long refname' '
60 git push long :refs/heads/$ref1440 &&
61 git -C long for-each-ref --format="%(subject)" refs/heads >actual &&
63 test_cmp expect actual