builtin/show: do not prune by pathspec
[git/mjg.git] / t / t0612-reftable-jgit-compatibility.sh
blobd0d7e80b492091d1949467f9835c35f622ae0bb4
1 #!/bin/sh
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-lib.sh
16 if ! test_have_prereq JGIT
17 then
18 skip_all='skipping reftable JGit tests; JGit is not present in PATH'
19 test_done
22 if ! test_have_prereq SHA1
23 then
24 skip_all='skipping reftable JGit tests; JGit does not support SHA256 reftables'
25 test_done
28 test_commit_jgit () {
29 touch "$1" &&
30 jgit add "$1" &&
31 jgit commit -m "$1"
34 test_same_refs () {
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
41 test_same_ref () {
42 git rev-parse "$1" >cgit.actual &&
43 jgit rev-parse "$1" >jgit.actual &&
44 test_cmp cgit.actual jgit.actual
47 test_same_reflog () {
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" &&
56 git init repo &&
58 cd repo &&
59 test_commit A &&
60 test_same_refs &&
61 test_same_ref HEAD &&
62 test_same_reflog HEAD
66 test_expect_success 'JGit repository can be read by CGit' '
67 test_when_finished "rm -rf repo" &&
68 jgit init repo &&
70 cd repo &&
72 touch file &&
73 jgit add file &&
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
78 # no HEAD at all.
79 jgit convert-ref-storage --format=reftable &&
81 test_same_refs &&
82 test_same_ref HEAD &&
83 # Interestingly, JGit cannot read its own reflog here. CGit can
84 # though.
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" &&
93 git init repo &&
95 cd repo &&
97 test_commit A &&
98 test_commit_jgit B &&
99 test_commit C &&
100 test_commit_jgit D &&
102 test_same_refs &&
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" &&
110 git init repo &&
112 cd repo &&
114 test_commit A &&
115 awk "
116 BEGIN {
117 print \"start\";
118 for (i = 0; i < 10000; i++)
119 printf \"create refs/heads/branch-%d HEAD\n\", i;
120 print \"commit\";
122 " >input &&
123 git update-ref --stdin <input &&
125 test_same_refs &&
126 test_same_ref refs/heads/branch-1 &&
127 test_same_ref refs/heads/branch-5738 &&
128 test_same_ref refs/heads/branch-9999
132 test_done