| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Junio C Hamano |
| 4 | # |
| 5 | |
| 6 | test_description='quoted output' |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | FN='濱野' |
| 11 | GN='純' |
| 12 | HT=' ' |
| 13 | DQ='"' |
| 14 | |
| 15 | test_have_prereq MINGW || |
| 16 | echo foo 2>/dev/null > "Name and an${HT}HT" |
| 17 | if ! test -f "Name and an${HT}HT" |
| 18 | then |
| 19 | # FAT/NTFS does not allow tabs in filenames |
| 20 | skip_all='Your filesystem does not allow tabs in filenames' |
| 21 | test_done |
| 22 | fi |
| 23 | |
| 24 | for_each_name () { |
| 25 | for name in \ |
| 26 | Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \ |
| 27 | "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \ |
| 28 | "With SP in it" "$FN/file" |
| 29 | do |
| 30 | eval "$1" |
| 31 | done |
| 32 | } |
| 33 | |
| 34 | test_expect_success 'setup' ' |
| 35 | |
| 36 | mkdir "$FN" && |
| 37 | for_each_name "echo initial >\"\$name\"" && |
| 38 | git add . && |
| 39 | git commit -q -m Initial && |
| 40 | |
| 41 | for_each_name "echo second >\"\$name\"" && |
| 42 | git commit -a -m Second && |
| 43 | |
| 44 | for_each_name "echo modified >\"\$name\"" |
| 45 | |
| 46 | ' |
| 47 | |
| 48 | test_expect_success 'setup expected files' ' |
| 49 | cat >expect.quoted <<\EOF && |
| 50 | Name |
| 51 | "Name and a\nLF" |
| 52 | "Name and an\tHT" |
| 53 | "Name\"" |
| 54 | With SP in it |
| 55 | "\346\277\261\351\207\216\t\347\264\224" |
| 56 | "\346\277\261\351\207\216\n\347\264\224" |
| 57 | "\346\277\261\351\207\216 \347\264\224" |
| 58 | "\346\277\261\351\207\216\"\347\264\224" |
| 59 | "\346\277\261\351\207\216/file" |
| 60 | "\346\277\261\351\207\216\347\264\224" |
| 61 | EOF |
| 62 | |
| 63 | # NOTE: do not quote this heredoc, Dash 0.5.13 has a bug with heredocs |
| 64 | # that contain multibyte chars. |
| 65 | cat >expect.raw <<EOF |
| 66 | Name |
| 67 | "Name and a\\nLF" |
| 68 | "Name and an\\tHT" |
| 69 | "Name\\"" |
| 70 | With SP in it |
| 71 | "濱野\\t純" |
| 72 | "濱野\\n純" |
| 73 | 濱野 純 |
| 74 | "濱野\\"純" |
| 75 | 濱野/file |
| 76 | 濱野純 |
| 77 | EOF |
| 78 | ' |
| 79 | |
| 80 | test_expect_success 'check fully quoted output from ls-files' ' |
| 81 | |
| 82 | git ls-files >current && test_cmp expect.quoted current |
| 83 | |
| 84 | ' |
| 85 | |
| 86 | test_expect_success 'check fully quoted output from diff-files' ' |
| 87 | |
| 88 | git diff --name-only >current && |
| 89 | test_cmp expect.quoted current |
| 90 | |
| 91 | ' |
| 92 | |
| 93 | test_expect_success 'check fully quoted output from diff-index' ' |
| 94 | |
| 95 | git diff --name-only HEAD >current && |
| 96 | test_cmp expect.quoted current |
| 97 | |
| 98 | ' |
| 99 | |
| 100 | test_expect_success 'check fully quoted output from diff-tree' ' |
| 101 | |
| 102 | git diff --name-only HEAD^ HEAD >current && |
| 103 | test_cmp expect.quoted current |
| 104 | |
| 105 | ' |
| 106 | |
| 107 | test_expect_success 'check fully quoted output from ls-tree' ' |
| 108 | |
| 109 | git ls-tree --name-only -r HEAD >current && |
| 110 | test_cmp expect.quoted current |
| 111 | |
| 112 | ' |
| 113 | |
| 114 | test_expect_success 'setting core.quotepath' ' |
| 115 | |
| 116 | git config --bool core.quotepath false |
| 117 | |
| 118 | ' |
| 119 | |
| 120 | test_expect_success 'check fully quoted output from ls-files' ' |
| 121 | |
| 122 | git ls-files >current && test_cmp expect.raw current |
| 123 | |
| 124 | ' |
| 125 | |
| 126 | test_expect_success 'check fully quoted output from diff-files' ' |
| 127 | |
| 128 | git diff --name-only >current && |
| 129 | test_cmp expect.raw current |
| 130 | |
| 131 | ' |
| 132 | |
| 133 | test_expect_success 'check fully quoted output from diff-index' ' |
| 134 | |
| 135 | git diff --name-only HEAD >current && |
| 136 | test_cmp expect.raw current |
| 137 | |
| 138 | ' |
| 139 | |
| 140 | test_expect_success 'check fully quoted output from diff-tree' ' |
| 141 | |
| 142 | git diff --name-only HEAD^ HEAD >current && |
| 143 | test_cmp expect.raw current |
| 144 | |
| 145 | ' |
| 146 | |
| 147 | test_expect_success 'check fully quoted output from ls-tree' ' |
| 148 | |
| 149 | git ls-tree --name-only -r HEAD >current && |
| 150 | test_cmp expect.raw current |
| 151 | |
| 152 | ' |
| 153 | |
| 154 | test_done |