Git fork
1#!/bin/sh
2
3test_description='git p4 handling of UTF-16 files without BOM'
4
5. ./lib-git-p4.sh
6
7UTF16="\227\000\227\000"
8
9test_expect_success 'start p4d' '
10 start_p4d
11'
12
13test_expect_success 'init depot with UTF-16 encoded file and artificially remove BOM' '
14 (
15 cd "$cli" &&
16 printf "$UTF16" >file1 &&
17 p4 add -t utf16 file1 &&
18 p4 submit -d "file1"
19 ) &&
20
21 (
22 cd db &&
23 p4d -jc &&
24 # P4D automatically adds a BOM. Remove it here to make the file invalid.
25 #
26 # Note that newer Perforce versions started to store files
27 # compressed in directories. The case statement handles both
28 # old and new layout.
29 case "$(echo depot/file1*)" in
30 depot/file1,v)
31 sed -e "\$d" depot/file1,v >depot/file1,v.new &&
32 mv depot/file1,v.new depot/file1,v &&
33 printf "@$UTF16@" >>depot/file1,v;;
34 depot/file1,d)
35 path="$(echo depot/file1,d/*.gz)" &&
36 gunzip -c "$path" >"$path.unzipped" &&
37 sed -e "\$d" "$path.unzipped" >"$path.new" &&
38 printf "$UTF16" >>"$path.new" &&
39 gzip -c "$path.new" >"$path" &&
40 rm "$path.unzipped" "$path.new";;
41 *)
42 BUG "unhandled p4d layout";;
43 esac &&
44 p4d -jrF checkpoint.1
45 )
46'
47
48test_expect_success 'clone depot with invalid UTF-16 file in verbose mode' '
49 git p4 clone --dest="$git" --verbose //depot &&
50 test_when_finished cleanup_git &&
51 (
52 cd "$git" &&
53 printf "$UTF16" >expect &&
54 test_cmp_bin expect file1
55 )
56'
57
58test_expect_failure 'clone depot with invalid UTF-16 file in non-verbose mode' '
59 git p4 clone --dest="$git" //depot
60'
61
62test_done