3 test_description
='reftables are compatible with JGit'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 GIT_TEST_DEFAULT_REF_FORMAT
=reftable
8 export GIT_TEST_DEFAULT_REF_FORMAT
10 # JGit does not support the 'link' DIRC extension.
11 GIT_TEST_SPLIT_INDEX
=0
12 export GIT_TEST_SPLIT_INDEX
14 TEST_PASSES_SANITIZE_LEAK
=true
17 if ! test_have_prereq JGIT
19 skip_all
='skipping reftable JGit tests; JGit is not present in PATH'
23 if ! test_have_prereq SHA1
25 skip_all
='skipping reftable JGit tests; JGit does not support SHA256 reftables'
36 git show-ref
--head >cgit.actual
&&
37 jgit show-ref
>jgit-tabs.actual
&&
38 tr "\t" " " <jgit-tabs.actual
>jgit.actual
&&
39 test_cmp cgit.actual jgit.actual
43 git rev-parse
"$1" >cgit.actual
&&
44 jgit rev-parse
"$1" >jgit.actual
&&
45 test_cmp cgit.actual jgit.actual
49 git reflog
"$*" >cgit.actual
&&
50 jgit reflog
"$*" >jgit-newline.actual
&&
51 sed '/^$/d' <jgit-newline.actual
>jgit.actual
&&
52 test_cmp cgit.actual jgit.actual
55 test_expect_success
'CGit repository can be read by JGit' '
56 test_when_finished "rm -rf repo" &&
67 test_expect_success
'JGit repository can be read by CGit' '
68 test_when_finished "rm -rf repo" &&
75 jgit commit -m "initial commit" &&
77 # Note that we must convert the ref storage after we have
78 # written the default branch. Otherwise JGit will end up with
80 jgit convert-ref-storage --format=reftable &&
84 # Interestingly, JGit cannot read its own reflog here. CGit can
86 printf "%s HEAD@{0}: commit (initial): initial commit" "$(git rev-parse --short HEAD)" >expect &&
87 git reflog HEAD >actual &&
88 test_cmp expect actual
92 test_expect_success
'mixed writes from JGit and CGit' '
93 test_when_finished "rm -rf repo" &&
101 test_commit_jgit D &&
104 test_same_ref HEAD &&
105 test_same_reflog HEAD
109 test_expect_success
'JGit can read multi-level index' '
110 test_when_finished "rm -rf repo" &&
119 for (i = 0; i < 10000; i++)
120 printf \"create refs/heads/branch-%d HEAD\n\", i;
124 git update-ref --stdin <input &&
127 test_same_ref refs/heads/branch-1 &&
128 test_same_ref refs/heads/branch-5738 &&
129 test_same_ref refs/heads/branch-9999