3 test_description
='git p4 handling of UTF-16 files without BOM'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 UTF16
="\227\000\227\000"
10 test_expect_success
'start p4d' '
14 test_expect_success
'init depot with UTF-16 encoded file and artificially remove BOM' '
17 printf "$UTF16" >file1 &&
18 p4 add -t utf16 file1 &&
25 # P4D automatically adds a BOM. Remove it here to make the file invalid.
27 # Note that newer Perforce versions started to store files
28 # compressed in directories. The case statement handles both
30 case "$(echo depot/file1*)" in
32 sed -e "\$d" depot/file1,v >depot/file1,v.new &&
33 mv depot/file1,v.new depot/file1,v &&
34 printf "@$UTF16@" >>depot/file1,v;;
36 path="$(echo depot/file1,d/*.gz)" &&
37 gunzip -c "$path" >"$path.unzipped" &&
38 sed -e "\$d" "$path.unzipped" >"$path.new" &&
39 printf "$UTF16" >>"$path.new" &&
40 gzip -c "$path.new" >"$path" &&
41 rm "$path.unzipped" "$path.new";;
43 BUG "unhandled p4d layout";;
49 test_expect_success
'clone depot with invalid UTF-16 file in verbose mode' '
50 git p4 clone --dest="$git" --verbose //depot &&
51 test_when_finished cleanup_git &&
54 printf "$UTF16" >expect &&
55 test_cmp_bin expect file1
59 test_expect_failure
'clone depot with invalid UTF-16 file in non-verbose mode' '
60 git p4 clone --dest="$git" //depot