Jeff King | 1e7ba0f | 2011-12-12 19:48:08 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test fetching of oddly-named refs' |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
Jeff King | 1e7ba0f | 2011-12-12 19:48:08 -0500 | [diff] [blame] | 7 | . ./test-lib.sh |
| 8 | |
| 9 | # afterwards we will have: |
| 10 | # HEAD - two |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 11 | # refs/for/refs/heads/main - one |
| 12 | # refs/heads/main - three |
Jeff King | 1e7ba0f | 2011-12-12 19:48:08 -0500 | [diff] [blame] | 13 | test_expect_success 'setup repo with odd suffix ref' ' |
| 14 | echo content >file && |
| 15 | git add . && |
| 16 | git commit -m one && |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 17 | git update-ref refs/for/refs/heads/main HEAD && |
Jeff King | 1e7ba0f | 2011-12-12 19:48:08 -0500 | [diff] [blame] | 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 && |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 28 | git --git-dir=suffix log -1 --format=%s refs/heads/main >actual && |
Jeff King | 1e7ba0f | 2011-12-12 19:48:08 -0500 | [diff] [blame] | 29 | test_cmp expect actual |
| 30 | ' |
| 31 | |
Jeff King | 8e9faf2 | 2014-12-10 04:47:02 -0500 | [diff] [blame] | 32 | test_expect_success 'try to create repo with absurdly long refname' ' |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 33 | ref240=$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID && |
Jeff King | 8e9faf2 | 2014-12-10 04:47:02 -0500 | [diff] [blame] | 34 | ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 && |
| 35 | git init long && |
| 36 | ( |
| 37 | cd long && |
| 38 | test_commit long && |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 39 | test_commit main |
Jeff King | 8e9faf2 | 2014-12-10 04:47:02 -0500 | [diff] [blame] | 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 |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 52 | main |
Jeff King | 8e9faf2 | 2014-12-10 04:47:02 -0500 | [diff] [blame] | 53 | EOF |
| 54 | git for-each-ref --format="%(subject)" refs/remotes/long >actual && |
| 55 | test_cmp expect actual |
| 56 | ' |
| 57 | |
| 58 | test_expect_success LONG_REF 'push handles extremely long refname' ' |
| 59 | git push long :refs/heads/$ref1440 && |
| 60 | git -C long for-each-ref --format="%(subject)" refs/heads >actual && |
Johannes Schindelin | 3ac8f63 | 2020-11-18 23:44:33 +0000 | [diff] [blame] | 61 | echo main >expect && |
Jeff King | 8e9faf2 | 2014-12-10 04:47:02 -0500 | [diff] [blame] | 62 | test_cmp expect actual |
| 63 | ' |
| 64 | |
Jeff King | 1e7ba0f | 2011-12-12 19:48:08 -0500 | [diff] [blame] | 65 | test_done |