Merge branch 'bc/clone-empty-repo-via-protocol-v0'
[alt-git.git] / t / t5527-fetch-odd-refs.sh
blob98ece27c6a0819093cd54ce19916456ce2136dae
1 #!/bin/sh
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
8 . ./test-lib.sh
10 # afterwards we will have:
11 # HEAD - two
12 # refs/for/refs/heads/main - one
13 # refs/heads/main - three
14 test_expect_success 'setup repo with odd suffix ref' '
15 echo content >file &&
16 git add . &&
17 git commit -m one &&
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 &&
23 git checkout HEAD^
26 test_expect_success 'suffix ref is ignored during fetch' '
27 git clone --bare file://"$PWD" suffix &&
28 echo three >expect &&
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 &&
36 git init long &&
38 cd long &&
39 test_commit long &&
40 test_commit main
41 ) &&
42 if git -C long update-ref refs/heads/$ref1440 long; then
43 test_set_prereq LONG_REF
44 else
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 &&
52 long
53 main
54 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 &&
62 echo main >expect &&
63 test_cmp expect actual
66 test_done