]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5527-fetch-odd-refs.sh
The seventh batch
[thirdparty/git.git] / t / t5527-fetch-odd-refs.sh
CommitLineData
1e7ba0f9
JK
1#!/bin/sh
2
3test_description='test fetching of oddly-named refs'
3ac8f630 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
1fdd31cf 7TEST_PASSES_SANITIZE_LEAK=true
1e7ba0f9
JK
8. ./test-lib.sh
9
10# afterwards we will have:
11# HEAD - two
3ac8f630
JS
12# refs/for/refs/heads/main - one
13# refs/heads/main - three
1e7ba0f9
JK
14test_expect_success 'setup repo with odd suffix ref' '
15 echo content >file &&
16 git add . &&
17 git commit -m one &&
3ac8f630 18 git update-ref refs/for/refs/heads/main HEAD &&
1e7ba0f9
JK
19 echo content >>file &&
20 git commit -a -m two &&
21 echo content >>file &&
22 git commit -a -m three &&
23 git checkout HEAD^
24'
25
26test_expect_success 'suffix ref is ignored during fetch' '
27 git clone --bare file://"$PWD" suffix &&
28 echo three >expect &&
3ac8f630 29 git --git-dir=suffix log -1 --format=%s refs/heads/main >actual &&
1e7ba0f9
JK
30 test_cmp expect actual
31'
32
8e9faf27 33test_expect_success 'try to create repo with absurdly long refname' '
8125a58b 34 ref240=$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID &&
8e9faf27
JK
35 ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 &&
36 git init long &&
37 (
38 cd long &&
39 test_commit long &&
3ac8f630 40 test_commit main
8e9faf27
JK
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"
46 fi
47'
48
49test_expect_success LONG_REF 'fetch handles extremely long refname' '
50 git fetch long refs/heads/*:refs/remotes/long/* &&
51 cat >expect <<-\EOF &&
52 long
3ac8f630 53 main
8e9faf27
JK
54 EOF
55 git for-each-ref --format="%(subject)" refs/remotes/long >actual &&
56 test_cmp expect actual
57'
58
59test_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 &&
3ac8f630 62 echo main >expect &&
8e9faf27
JK
63 test_cmp expect actual
64'
65
1e7ba0f9 66test_done