]>
Commit | Line | Data |
---|---|---|
1e7ba0f9 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='test fetching of oddly-named refs' | |
3ac8f630 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
1fdd31cf | 7 | TEST_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 |
14 | test_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 | ||
26 | test_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 | 33 | test_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 | ||
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 | |
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 | ||
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 && | |
3ac8f630 | 62 | echo main >expect && |
8e9faf27 JK |
63 | test_cmp expect actual |
64 | ' | |
65 | ||
1e7ba0f9 | 66 | test_done |