diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:47:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:47:53 +0000 |
commit | c8bae7493d2f2910b57f13ded012e86bdcfb0532 (patch) | |
tree | 24e09d9f84dec336720cf393e156089ca2835791 /t/t5527-fetch-odd-refs.sh | |
parent | Initial commit. (diff) | |
download | git-17a789943131483bc454986d1be6da6caaabce8c.tar.xz git-17a789943131483bc454986d1be6da6caaabce8c.zip |
Adding upstream version 1:2.39.2.upstream/1%2.39.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/t5527-fetch-odd-refs.sh')
-rwxr-xr-x | t/t5527-fetch-odd-refs.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/t/t5527-fetch-odd-refs.sh b/t/t5527-fetch-odd-refs.sh new file mode 100755 index 0000000..e2770e4 --- /dev/null +++ b/t/t5527-fetch-odd-refs.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +test_description='test fetching of oddly-named refs' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./test-lib.sh + +# afterwards we will have: +# HEAD - two +# refs/for/refs/heads/main - one +# refs/heads/main - three +test_expect_success 'setup repo with odd suffix ref' ' + echo content >file && + git add . && + git commit -m one && + git update-ref refs/for/refs/heads/main HEAD && + echo content >>file && + git commit -a -m two && + echo content >>file && + git commit -a -m three && + git checkout HEAD^ +' + +test_expect_success 'suffix ref is ignored during fetch' ' + git clone --bare file://"$PWD" suffix && + echo three >expect && + git --git-dir=suffix log -1 --format=%s refs/heads/main >actual && + test_cmp expect actual +' + +test_expect_success 'try to create repo with absurdly long refname' ' + ref240=$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID/$ZERO_OID && + ref1440=$ref240/$ref240/$ref240/$ref240/$ref240/$ref240 && + git init long && + ( + cd long && + test_commit long && + test_commit main + ) && + if git -C long update-ref refs/heads/$ref1440 long; then + test_set_prereq LONG_REF + else + echo >&2 "long refs not supported" + fi +' + +test_expect_success LONG_REF 'fetch handles extremely long refname' ' + git fetch long refs/heads/*:refs/remotes/long/* && + cat >expect <<-\EOF && + long + main + EOF + git for-each-ref --format="%(subject)" refs/remotes/long >actual && + test_cmp expect actual +' + +test_expect_success LONG_REF 'push handles extremely long refname' ' + git push long :refs/heads/$ref1440 && + git -C long for-each-ref --format="%(subject)" refs/heads >actual && + echo main >expect && + test_cmp expect actual +' + +test_done |