The eighth batch
[git.git] / t / t9825-git-p4-handle-utf16-without-bom.sh
blobd0b86537dd975a5c905a318e1df1a4672ed68e73
1 #!/bin/sh
3 test_description='git p4 handling of UTF-16 files without BOM'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 UTF16="\227\000\227\000"
10 test_expect_success 'start p4d' '
11 start_p4d
14 test_expect_success 'init depot with UTF-16 encoded file and artificially remove BOM' '
16 cd "$cli" &&
17 printf "$UTF16" >file1 &&
18 p4 add -t utf16 file1 &&
19 p4 submit -d "file1"
20 ) &&
23 cd db &&
24 p4d -jc &&
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
29 # old and new layout.
30 case "$(echo depot/file1*)" in
31 depot/file1,v)
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;;
35 depot/file1,d)
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";;
44 esac &&
45 p4d -jrF checkpoint.1
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 &&
53 cd "$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
63 test_done