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
16 if ! test_have_prereq JGIT
18 skip_all
='skipping reftable JGit tests; JGit is not present in PATH'
22 if ! test_have_prereq SHA1
24 skip_all
='skipping reftable JGit tests; JGit does not support SHA256 reftables'
35 git show-ref
--head >cgit.actual
&&
36 jgit show-ref
>jgit-tabs.actual
&&
37 tr "\t" " " <jgit-tabs.actual
>jgit.actual
&&
38 test_cmp cgit.actual jgit.actual
42 git rev-parse
"$1" >cgit.actual
&&
43 jgit rev-parse
"$1" >jgit.actual
&&
44 test_cmp cgit.actual jgit.actual
48 git reflog
"$*" >cgit.actual
&&
49 jgit reflog
"$*" >jgit-newline.actual
&&
50 sed '/^$/d' <jgit-newline.actual
>jgit.actual
&&
51 test_cmp cgit.actual jgit.actual
54 test_expect_success
'CGit repository can be read by JGit' '
55 test_when_finished "rm -rf repo" &&
66 test_expect_success
'JGit repository can be read by CGit' '
67 test_when_finished "rm -rf repo" &&
74 jgit commit -m "initial commit" &&
76 # Note that we must convert the ref storage after we have
77 # written the default branch. Otherwise JGit will end up with
79 jgit convert-ref-storage --format=reftable &&
83 # Interestingly, JGit cannot read its own reflog here. CGit can
85 printf "%s HEAD@{0}: commit (initial): initial commit" "$(git rev-parse --short HEAD)" >expect &&
86 git reflog HEAD >actual &&
87 test_cmp expect actual
91 test_expect_success
'mixed writes from JGit and CGit' '
92 test_when_finished "rm -rf repo" &&
100 test_commit_jgit D &&
103 test_same_ref HEAD &&
104 test_same_reflog HEAD
108 test_expect_success
'JGit can read multi-level index' '
109 test_when_finished "rm -rf repo" &&
118 for (i = 0; i < 10000; i++)
119 printf \"create refs/heads/branch-%d HEAD\n\", i;
123 git update-ref --stdin <input &&
126 test_same_ref refs/heads/branch-1 &&
127 test_same_ref refs/heads/branch-5738 &&
128 test_same_ref refs/heads/branch-9999