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/t5001-archive-attr.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 / t5001-archive-attr.sh` 165 lines ยท 5557 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='git archive attribute tests' 4 5 TEST_CREATE_REPO_NO_TEMPLATE=1 6 . ./test-lib.sh 7 8 SUBSTFORMAT='%H (%h)%n' 9 10 test_expect_exists() { 11 test_expect_${2:-success} " $1 exists" "test -e $1" 12 } 13 14 test_expect_missing() { 15 test_expect_${2:-success} " $1 does not exist" "test ! -e $1" 16 } 17 18 extract_tar_to_dir () { 19 (mkdir "$1" && cd "$1" && "$TAR" xf -) <"$1.tar" 20 } 21 22 test_expect_success 'setup' ' 23 echo ignored >ignored && 24 mkdir .git/info && 25 echo ignored export-ignore >>.git/info/attributes && 26 git add ignored && 27 28 echo ignored by tree >ignored-by-tree && 29 echo ignored-by-tree export-ignore >.gitattributes && 30 mkdir ignored-by-tree.d && 31 >ignored-by-tree.d/file && 32 echo ignored-by-tree.d export-ignore >>.gitattributes && 33 git add ignored-by-tree ignored-by-tree.d .gitattributes && 34 35 mkdir subdir && 36 >subdir/included && 37 >subdir/ignored-by-subtree && 38 >subdir/ignored-by-tree && 39 echo ignored-by-subtree export-ignore >subdir/.gitattributes && 40 git add subdir && 41 42 echo ignored by worktree >ignored-by-worktree && 43 echo ignored-by-worktree export-ignore >.gitattributes && 44 git add ignored-by-worktree && 45 46 mkdir excluded-by-pathspec.d && 47 >excluded-by-pathspec.d/file && 48 git add excluded-by-pathspec.d && 49 50 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >nosubstfile && 51 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >substfile1 && 52 printf "A not substituted O" >substfile2 && 53 echo "substfile?" export-subst >>.git/info/attributes && 54 git add nosubstfile substfile1 substfile2 && 55 56 git commit -m. && 57 58 git clone --template= --bare . bare && 59 mkdir bare/info && 60 cp .git/info/attributes bare/info/attributes 61 ' 62 63 test_expect_success 'git archive' ' 64 git archive HEAD >archive.tar && 65 (mkdir archive && cd archive && "$TAR" xf -) archive-pathspec.tar && 78 extract_tar_to_dir archive-pathspec 79 ' 80 81 test_expect_missing archive-pathspec/ignored 82 test_expect_missing archive-pathspec/ignored-by-tree 83 test_expect_missing archive-pathspec/ignored-by-tree.d 84 test_expect_missing archive-pathspec/ignored-by-tree.d/file 85 test_expect_exists archive-pathspec/ignored-by-worktree 86 test_expect_missing archive-pathspec/excluded-by-pathspec.d 87 test_expect_missing archive-pathspec/excluded-by-pathspec.d/file 88 89 test_expect_success 'git archive with wildcard pathspec' ' 90 git archive HEAD ":!excluded-by-p*" >archive-pathspec-wildcard.tar && 91 extract_tar_to_dir archive-pathspec-wildcard 92 ' 93 94 test_expect_missing archive-pathspec-wildcard/ignored 95 test_expect_missing archive-pathspec-wildcard/ignored-by-tree 96 test_expect_missing archive-pathspec-wildcard/ignored-by-tree.d 97 test_expect_missing archive-pathspec-wildcard/ignored-by-tree.d/file 98 test_expect_exists archive-pathspec-wildcard/ignored-by-worktree 99 test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d 100 test_expect_missing archive-pathspec-wildcard/excluded-by-pathspec.d/file 101 102 test_expect_success 'git -C subdir archive' ' 103 git -C subdir archive HEAD >archive-subdir.tar && 104 extract_tar_to_dir archive-subdir 105 ' 106 107 test_expect_exists archive-subdir/included 108 test_expect_missing archive-subdir/ignored-by-subtree 109 test_expect_missing archive-subdir/ignored-by-tree 110 111 test_expect_success 'git archive with worktree attributes' ' 112 git archive --worktree-attributes HEAD >worktree.tar && 113 (mkdir worktree && cd worktree && "$TAR" xf -) worktree.tar && 122 (mkdir worktree2 && cd worktree2 && "$TAR" xf -) bare-archive.tar && 131 test_cmp_bin archive.tar bare-archive.tar 132 ' 133 134 test_expect_success 'git archive with worktree attributes, bare' ' 135 (cd bare && 136 git -c attr.tree=HEAD archive --worktree-attributes HEAD) >bare-worktree.tar && 137 (mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) substfile1.expected && 146 test_cmp nosubstfile archive/nosubstfile && 147 test_cmp substfile1.expected archive/substfile1 && 148 test_cmp substfile2 archive/substfile2 149 ' 150 151 test_expect_success 'export-subst expands %(describe) once' ' 152 echo "\$Format:%(describe)\$" >substfile3 && 153 echo "\$Format:%(describe)\$" >>substfile3 && 154 echo "\$Format:%(describe)${LF}%(describe)\$" >substfile4 && 155 git add substfile[34] && 156 git commit -m export-subst-describe && 157 git tag -m export-subst-describe export-subst-describe && 158 git archive HEAD >archive-describe.tar && 159 extract_tar_to_dir archive-describe && 160 desc=$(git describe) && 161 grep -F "$desc" archive-describe/substfile[34] >substituted && 162 test_line_count = 1 substituted 163 ' 164 165 test_done