t / t9825-git-p4-handle-utf16-without-bom.shon commit submodule--helper: add a missing \n (1a87871)
   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                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
  32test_expect_success '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
  42test_expect_failure 'clone depot with invalid UTF-16 file in non-verbose mode' '
  43        git p4 clone --dest="$git" //depot
  44'
  45
  46test_expect_success 'kill p4d' '
  47        kill_p4d
  48'
  49
  50test_done