git-p4: ignore apple filetype

Revert 97a21ca (git-p4: stop ignoring apple filetype, 2011-10-16) and add a test case. Reported-by: Michael Wookey <michaelwookey@gmail.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pete Wyckoff committed Nov 5, 2011 at 13:36 UTC 9f7ef0eaf2e54609128add5e8f9b506bdbb81dff
2 files changed +44
contrib/fast-import/git-p4
+13
@@ -1272,6 +1272,19 @@ class P4Sync(Command, P4UserMap):
1272 text = p4_read_pipe('print -q -o - "%s"' % file['depotFile'])
1273 contents = [ text ]
1274
1275 + if type_base == "apple":
1276 + # Apple filetype files will be streamed as a concatenation of
1277 + # its appledouble header and the contents. This is useless
1278 + # on both macs and non-macs. If using "print -q -o xx", it
1279 + # will create "xx" with the data, and "%xx" with the header.
1280 + # This is also not very useful.
1281 + #
1282 + # Ideally, someday, this script can learn how to generate
1283 + # appledouble files directly and import those to git, but
1284 + # non-mac machines can never find a use for apple filetype.
1285 + print "\nIgnoring apple filetype file %s" % file['depotFile']
1286 + return
1287 +
1288 # Perhaps windows wants unicode, utf16 newlines translated too;
1289 # but this is not doing it.
1290 if self.isWindows and type_base == "text":
t/t9802-git-p4-filetype.sh
+31
@@ -101,6 +101,37 @@ test_expect_success 'keyword file test' '
101 )
102 '
103
104 +build_gendouble() {
105 + cat >gendouble.py <<-\EOF
106 + import sys
107 + import struct
108 + import array
109 +
110 + s = array.array("c", '\0' * 26)
111 + struct.pack_into(">L", s, 0, 0x00051607) # AppleDouble
112 + struct.pack_into(">L", s, 4, 0x00020000) # version 2
113 + s.tofile(sys.stdout)
114 + EOF
115 +}
116 +
117 +test_expect_success 'ignore apple' '
118 + test_when_finished rm -f gendouble.py &&
119 + build_gendouble &&
120 + (
121 + cd "$cli" &&
122 + test-genrandom apple 1024 >double.png &&
123 + "$PYTHON_PATH" "$TRASH_DIRECTORY/gendouble.py" >%double.png &&
124 + p4 add -t apple double.png &&
125 + p4 submit -d appledouble
126 + ) &&
127 + test_when_finished cleanup_git &&
128 + "$GITP4" clone --dest="$git" //depot@all &&
129 + (
130 + cd "$git" &&
131 + test ! -f double.png
132 + )
133 +'
134 +
135 test_expect_success 'kill p4d' '
136 kill_p4d
137 '