archive: handle commits with an empty tree
[git/jnareb-git.git] / t / t9802-git-p4-filetype.sh
blobaae1a3f816eb0f57f84053d74246a8db7d7529d8
1 #!/bin/sh
3 test_description='git p4 filetype tests'
5 . ./lib-git-p4.sh
7 test_expect_success 'start p4d' '
8 start_p4d
11 test_expect_success 'utf-16 file create' '
13 cd "$cli" &&
15 # p4 saves this verbatim
16 printf "three\nline\ntext\n" >f-ascii &&
17 p4 add -t text f-ascii &&
19 # p4 adds \377\376 header
20 cp f-ascii f-ascii-as-utf16 &&
21 p4 add -t utf16 f-ascii-as-utf16 &&
23 # p4 saves this exactly as iconv produced it
24 printf "three\nline\ntext\n" | iconv -f ascii -t utf-16 >f-utf16 &&
25 p4 add -t utf16 f-utf16 &&
27 # this also is unchanged
28 cp f-utf16 f-utf16-as-text &&
29 p4 add -t text f-utf16-as-text &&
31 p4 submit -d "f files" &&
33 # force update of client files
34 p4 sync -f
38 test_expect_success 'utf-16 file test' '
39 test_when_finished cleanup_git &&
40 git p4 clone --dest="$git" //depot@all &&
42 cd "$git" &&
44 test_cmp "$cli/f-ascii" f-ascii &&
45 test_cmp "$cli/f-ascii-as-utf16" f-ascii-as-utf16 &&
46 test_cmp "$cli/f-utf16" f-utf16 &&
47 test_cmp "$cli/f-utf16-as-text" f-utf16-as-text
51 test_expect_success 'keyword file create' '
53 cd "$cli" &&
55 printf "id\n\$Id\$\n\$Author\$\ntext\n" >k-text-k &&
56 p4 add -t text+k k-text-k &&
58 cp k-text-k k-text-ko &&
59 p4 add -t text+ko k-text-ko &&
61 cat k-text-k | iconv -f ascii -t utf-16 >k-utf16-k &&
62 p4 add -t utf16+k k-utf16-k &&
64 cp k-utf16-k k-utf16-ko &&
65 p4 add -t utf16+ko k-utf16-ko &&
67 p4 submit -d "k files" &&
68 p4 sync -f
72 build_smush() {
73 cat >k_smush.py <<-\EOF &&
74 import re, sys
75 sys.stdout.write(re.sub(r'(?i)\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$', r'$\1$', sys.stdin.read()))
76 EOF
77 cat >ko_smush.py <<-\EOF
78 import re, sys
79 sys.stdout.write(re.sub(r'(?i)\$(Id|Header):[^$]*\$', r'$\1$', sys.stdin.read()))
80 EOF
83 test_expect_success 'keyword file test' '
84 build_smush &&
85 test_when_finished rm -f k_smush.py ko_smush.py &&
86 test_when_finished cleanup_git &&
87 git p4 clone --dest="$git" //depot@all &&
89 cd "$git" &&
91 # text, ensure unexpanded
92 "$PYTHON_PATH" "$TRASH_DIRECTORY/k_smush.py" <"$cli/k-text-k" >cli-k-text-k-smush &&
93 test_cmp cli-k-text-k-smush k-text-k &&
94 "$PYTHON_PATH" "$TRASH_DIRECTORY/ko_smush.py" <"$cli/k-text-ko" >cli-k-text-ko-smush &&
95 test_cmp cli-k-text-ko-smush k-text-ko &&
97 # utf16, even though p4 expands keywords, git p4 does not
98 # try to undo that
99 test_cmp "$cli/k-utf16-k" k-utf16-k &&
100 test_cmp "$cli/k-utf16-ko" k-utf16-ko
104 build_gendouble() {
105 cat >gendouble.py <<-\EOF
106 import sys
107 import struct
109 s = struct.pack(">LL18s",
110 0x00051607, # AppleDouble
111 0x00020000, # version 2
112 "" # pad to 26 bytes
114 sys.stdout.write(s)
118 test_expect_success 'ignore apple' '
119 test_when_finished rm -f gendouble.py &&
120 build_gendouble &&
122 cd "$cli" &&
123 test-genrandom apple 1024 >double.png &&
124 "$PYTHON_PATH" "$TRASH_DIRECTORY/gendouble.py" >%double.png &&
125 p4 add -t apple double.png &&
126 p4 submit -d appledouble
127 ) &&
128 test_when_finished cleanup_git &&
129 git p4 clone --dest="$git" //depot@all &&
131 cd "$git" &&
132 test ! -f double.png
136 test_expect_success 'kill p4d' '
137 kill_p4d
140 test_done