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/t3300-funny-names.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 / t3300-funny-names.sh` 217 lines ยท 5432 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2005 Junio C Hamano 4 # 5 6 test_description='Pathnames with funny characters. 7 8 This test tries pathnames with funny characters in the working 9 tree, index, and tree objects. 10 ' 11 12 . ./test-lib.sh 13 14 HT=' ' 15 16 test_have_prereq MINGW || 17 echo 2>/dev/null > "Name with an${HT}HT" 18 if ! test -f "Name with an${HT}HT" 19 then 20 # since FAT/NTFS does not allow tabs in filenames, skip this test 21 skip_all='Your filesystem does not allow tabs in filenames' 22 test_done 23 fi 24 25 p0='no-funny' 26 p1='tabs ," (dq) and spaces' 27 p2='just space' 28 29 test_expect_success 'setup' ' 30 cat >"$p0" <<-\EOF && 31 1. A quick brown fox jumps over the lazy cat, oops dog. 32 2. A quick brown fox jumps over the lazy cat, oops dog. 33 3. A quick brown fox jumps over the lazy cat, oops dog. 34 EOF 35 36 { cat "$p0" >"$p1" || :; } && 37 { echo "Foo Bar Baz" >"$p2" || :; } 38 ' 39 40 test_expect_success 'setup: populate index and tree' ' 41 git update-index --add "$p0" "$p2" && 42 t0=$(git write-tree) 43 ' 44 45 test_expect_success 'ls-files prints space in filename verbatim' ' 46 printf "%s\n" "just space" no-funny >expected && 47 git ls-files >current && 48 test_cmp expected current 49 ' 50 51 test_expect_success 'setup: add funny filename' ' 52 git update-index --add "$p1" && 53 t1=$(git write-tree) 54 ' 55 56 test_expect_success 'ls-files quotes funny filename' ' 57 cat >expected <<-\EOF && 58 just space 59 no-funny 60 "tabs\t,\" (dq) and spaces" 61 EOF 62 git ls-files >current && 63 test_cmp expected current 64 ' 65 66 test_expect_success 'ls-files -z does not quote funny filename' ' 67 cat >expected <<-\EOF && 68 just space 69 no-funny 70 tabs ," (dq) and spaces 71 EOF 72 git ls-files -z >ls-files.z && 73 tr "\000" "\012" current && 74 test_cmp expected current 75 ' 76 77 test_expect_success 'ls-tree quotes funny filename' ' 78 cat >expected <<-\EOF && 79 just space 80 no-funny 81 "tabs\t,\" (dq) and spaces" 82 EOF 83 git ls-tree -r $t1 >ls-tree && 84 sed -e "s/^[^ ]* //" current && 85 test_cmp expected current 86 ' 87 88 test_expect_success 'diff-index --name-status quotes funny filename' ' 89 cat >expected <<-\EOF && 90 A "tabs\t,\" (dq) and spaces" 91 EOF 92 git diff-index --name-status $t0 >current && 93 test_cmp expected current 94 ' 95 96 test_expect_success 'diff-tree --name-status quotes funny filename' ' 97 cat >expected <<-\EOF && 98 A "tabs\t,\" (dq) and spaces" 99 EOF 100 git diff-tree --name-status $t0 $t1 >current && 101 test_cmp expected current 102 ' 103 104 test_expect_success 'diff-index -z does not quote funny filename' ' 105 cat >expected <<-\EOF && 106 A 107 tabs ," (dq) and spaces 108 EOF 109 git diff-index -z --name-status $t0 >diff-index.z && 110 tr "\000" "\012" current && 111 test_cmp expected current 112 ' 113 114 test_expect_success 'diff-tree -z does not quote funny filename' ' 115 cat >expected <<-\EOF && 116 A 117 tabs ," (dq) and spaces 118 EOF 119 git diff-tree -z --name-status $t0 $t1 >diff-tree.z && 120 tr "\000" "\012" current && 121 test_cmp expected current 122 ' 123 124 test_expect_success 'diff-tree --find-copies-harder quotes funny filename' ' 125 cat >expected <<-\EOF && 126 CNUM no-funny "tabs\t,\" (dq) and spaces" 127 EOF 128 git diff-tree -C --find-copies-harder --name-status $t0 $t1 >out && 129 sed -e "s/^C[0-9]*/CNUM/" current && 130 test_cmp expected current 131 ' 132 133 test_expect_success 'setup: remove unfunny index entry' ' 134 git update-index --force-remove "$p0" 135 ' 136 137 test_expect_success 'diff-tree -M quotes funny filename' ' 138 cat >expected <<-\EOF && 139 RNUM no-funny "tabs\t,\" (dq) and spaces" 140 EOF 141 git diff-index -M --name-status $t0 >out && 142 sed -e "s/^R[0-9]*/RNUM/" current && 143 test_cmp expected current 144 ' 145 146 test_expect_success 'diff-index -M -p quotes funny filename' ' 147 cat >expected <<-\EOF && 148 diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" 149 similarity index NUM% 150 rename from no-funny 151 rename to "tabs\t,\" (dq) and spaces" 152 EOF 153 git diff-index -M -p $t0 >diff && 154 sed -e "s/index [0-9]*%/index NUM%/" current && 155 test_cmp expected current 156 ' 157 158 test_expect_success 'setup: mode change' ' 159 chmod +x "$p1" 160 ' 161 162 test_expect_success 'diff-index -M -p with mode change quotes funny filename' ' 163 cat >expected <<-\EOF && 164 diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" 165 old mode 100644 166 new mode 100755 167 similarity index NUM% 168 rename from no-funny 169 rename to "tabs\t,\" (dq) and spaces" 170 EOF 171 git diff-index -M -p $t0 >diff && 172 sed -e "s/index [0-9]*%/index NUM%/" current && 173 test_cmp expected current 174 ' 175 176 test_expect_success 'diffstat for rename quotes funny filename' ' 177 cat >expected <<-\EOF && 178 "tabs\t,\" (dq) and spaces" 179 1 file changed, 0 insertions(+), 0 deletions(-) 180 EOF 181 git diff-index -M -p $t0 >diff && 182 git apply --stat diffstat && 183 sed -e "s/|.*//" -e "s/ *\$//" current && 184 test_cmp expected current 185 ' 186 187 test_expect_success 'numstat for rename quotes funny filename' ' 188 cat >expected <<-\EOF && 189 0 0 "tabs\t,\" (dq) and spaces" 190 EOF 191 git diff-index -M -p $t0 >diff && 192 git apply --numstat current && 193 test_cmp expected current 194 ' 195 196 test_expect_success 'numstat without -M quotes funny filename' ' 197 cat >expected <<-\EOF && 198 0 3 no-funny 199 3 0 "tabs\t,\" (dq) and spaces" 200 EOF 201 git diff-index -p $t0 >diff && 202 git apply --numstat current && 203 test_cmp expected current 204 ' 205 206 test_expect_success 'numstat for non-git rename diff quotes funny filename' ' 207 cat >expected <<-\EOF && 208 0 3 no-funny 209 3 0 "tabs\t,\" (dq) and spaces" 210 EOF 211 git diff-index -p $t0 >git-diff && 212 sed -ne "/^[-+@]/p" diff && 213 git apply --numstat current && 214 test_cmp expected current 215 ' 216 217 test_done