Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t0612-reftable-jgit-compatibility.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t0612-reftable-jgit-compatibility.sh` 129 lines ยท 2817 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='reftables are compatible with JGit' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 GIT_TEST_DEFAULT_REF_STORAGE_FORMAT=reftable 8 export GIT_TEST_DEFAULT_REF_STORAGE_FORMAT 9 10 # JGit does not support the 'link' DIRC extension. 11 GIT_TEST_SPLIT_INDEX=0 12 export GIT_TEST_SPLIT_INDEX 13 14 . ./test-lib.sh 15 16 if ! test_have_prereq JGIT 17 then 18 skip_all='skipping reftable JGit tests; JGit is not present in PATH' 19 test_done 20 fi 21 22 if ! test_have_prereq SHA1 23 then 24 skip_all='skipping reftable JGit tests; JGit does not support SHA256 reftables' 25 test_done 26 fi 27 28 test_commit_jgit () { 29 touch "$1" && 30 jgit add "$1" && 31 jgit commit -m "$1" 32 } 33 34 test_same_refs () { 35 git show-ref --head >cgit.actual && 36 jgit show-ref >jgit-tabs.actual && 37 tr "\t" " " jgit.actual && 38 test_cmp cgit.actual jgit.actual 39 } 40 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 45 } 46 47 test_same_reflog () { 48 git reflog "$*" >cgit.actual && 49 jgit reflog "$*" >jgit-newline.actual && 50 sed '/^$/d' jgit.actual && 51 test_cmp cgit.actual jgit.actual 52 } 53 54 test_expect_success 'CGit repository can be read by JGit' ' 55 test_when_finished "rm -rf repo" && 56 git init repo && 57 ( 58 cd repo && 59 test_commit A && 60 test_same_refs && 61 test_same_ref HEAD && 62 test_same_reflog HEAD 63 ) 64 ' 65 66 test_expect_success 'JGit repository can be read by CGit' ' 67 test_when_finished "rm -rf repo" && 68 jgit init repo && 69 ( 70 cd repo && 71 72 touch file && 73 jgit add file && 74 jgit commit -m "initial commit" && 75 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 && 80 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 88 ) 89 ' 90 91 test_expect_success 'mixed writes from JGit and CGit' ' 92 test_when_finished "rm -rf repo" && 93 git init repo && 94 ( 95 cd repo && 96 97 test_commit A && 98 test_commit_jgit B && 99 test_commit C && 100 test_commit_jgit D && 101 102 test_same_refs && 103 test_same_ref HEAD && 104 test_same_reflog HEAD 105 ) 106 ' 107 108 test_expect_success 'JGit can read multi-level index' ' 109 test_when_finished "rm -rf repo" && 110 git init repo && 111 ( 112 cd repo && 113 114 test_commit A && 115 { 116 echo start && 117 test_seq -f "create refs/heads/branch-%d HEAD" 10000 && 118 echo commit 119 } >input && 120 git update-ref --stdin