Lars Schneider | fe18a0f | 2015-09-21 12:01:40 +0200 | [diff] [blame] | 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 | |
Lars Schneider | 1f5f390 | 2015-09-21 12:01:41 +0200 | [diff] [blame] | 32 | test_expect_success 'clone depot with invalid UTF-16 file in verbose mode' ' |
Lars Schneider | fe18a0f | 2015-09-21 12:01:40 +0200 | [diff] [blame] | 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 | |
Lars Schneider | fe18a0f | 2015-09-21 12:01:40 +0200 | [diff] [blame] | 46 | test_done |