]>
| 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 | ||
| 1e7ba0f9 JK |
7 | . ./test-lib.sh |
| 8 | ||
| 9 | # afterwards we will have: | |
| 10 | # HEAD - two | |
| 3ac8f630 JS |
11 | # refs/for/refs/heads/main - one |
| 12 | # refs/heads/main - three | |
| 1e7ba0f9 JK |
13 | test_expect_success 'setup repo with odd suffix ref' ' |
| 14 | echo content >file && | |
| 15 | git add . && | |
| 16 | git commit -m one && | |
| 3ac8f630 | 17 | git update-ref refs/for/refs/heads/main HEAD && |
| 1e7ba0f9 JK |
18 | echo content >>file && |
| 19 | git commit -a -m two && | |
| 20 | echo content >>file && | |
| 21 | git commit -a -m three && | |
| 22 | git checkout HEAD^ | |
| 23 | ' | |
| 24 | ||
| 25 | test_expect_success 'suffix ref is ignored during fetch' ' | |
| 26 | git clone --bare file://"$PWD" suffix && | |
| 27 | echo three >expect && | |
| 3ac8f630 | 28 | git --git-dir=suffix log -1 --format=%s refs/heads/main >actual && |
| 1e7ba0f9 JK |
29 | test_cmp expect actual |
| 30 | ' | |
| 31 | ||
| 8e9faf27 | 32 | test_expect_success 'try to create repo with absurdly long refname' ' |
| 8125a58b | 33 | ref240=$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID && |
| 8e9faf27 JK |
34 | ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 && |
| 35 | git init long && | |
| 36 | ( | |
| 37 | cd long && | |
| 38 | test_commit long && | |
| 3ac8f630 | 39 | test_commit main |
| 8e9faf27 JK |
40 | ) && |
| 41 | if git -C long update-ref refs/heads/$ref1440 long; then | |
| 42 | test_set_prereq LONG_REF | |
| 43 | else | |
| 44 | echo >&2 "long refs not supported" | |
| 45 | fi | |
| 46 | ' | |
| 47 | ||
| 48 | test_expect_success LONG_REF 'fetch handles extremely long refname' ' | |
| 49 | git fetch long refs/heads/*:refs/remotes/long/* && | |
| 50 | cat >expect <<-\EOF && | |
| 51 | long | |
| 3ac8f630 | 52 | main |
| 8e9faf27 | 53 | EOF |
| 3f763ddf BF |
54 | git for-each-ref --format="%(subject)" refs/remotes/long \ |
| 55 | --exclude=refs/remotes/long/HEAD >actual && | |
| 8e9faf27 JK |
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 |