Skip to content

Commit fe18a0f

Browse files
larsxschneidergitster
authored andcommitted
git-p4: add test case for "Translation of file content failed" error
A P4 repository can get into a state where it contains a file with type UTF-16 that does not contain a valid UTF-16 BOM. If git-p4 attempts to retrieve the file then the process crashes with a "Translation of file content failed" error. More info here: http://answers.perforce.com/articles/KB/3117 Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45733fa commit fe18a0f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
test_description='git p4 handling of UTF-16 files without BOM'
4+
5+
. ./lib-git-p4.sh
6+
7+
UTF16="\227\000\227\000"
8+
9+
test_expect_success 'start p4d' '
10+
start_p4d
11+
'
12+
13+
test_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+
sed -e "\$d" depot/file1,v >depot/file1,v.new &&
26+
mv depot/file1,v.new depot/file1,v &&
27+
printf "@$UTF16@" >>depot/file1,v &&
28+
p4d -jrF checkpoint.1
29+
)
30+
'
31+
32+
test_expect_failure 'clone depot with invalid UTF-16 file in verbose mode' '
33+
git p4 clone --dest="$git" --verbose //depot &&
34+
test_when_finished cleanup_git &&
35+
(
36+
cd "$git" &&
37+
printf "$UTF16" >expect &&
38+
test_cmp_bin expect file1
39+
)
40+
'
41+
42+
test_expect_failure 'clone depot with invalid UTF-16 file in non-verbose mode' '
43+
git p4 clone --dest="$git" //depot
44+
'
45+
46+
test_expect_success 'kill p4d' '
47+
kill_p4d
48+
'
49+
50+
test_done

0 commit comments

Comments
 (0)