archive-zip: mark text files in archives
commit4aff646d17e81084000100da586bef8f9d6a17a5
authorRené Scharfe <l.s.r@web.de>
Thu, 5 Mar 2015 19:06:02 +0000 (5 20:06 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2015 23:27:48 +0000 (5 15:27 -0800)
tree622066ccb07b949730584e1833554b54aadeb87e
parent282616c72d1d08a77ca4fe1186cb708c38408d87
archive-zip: mark text files in archives

Set the text flag for ZIP archive entries that look like text files so
that unzip -a can be used to perform end-of-line conversions.  Info-ZIP
zip does the same.

Detect binary files the same way as git diff and git grep do, namely by
checking for the attribute "diff" and its negation "-diff", and if none
is found by falling back to checking for the presence of NUL bytes in
the first few bytes of the file contents.

7-Zip, Windows' built-in ZIP functionality and Info-ZIP unzip without
the switch -a are not affected by the change and still extract text
files without doing any end-of-line conversions.

NB: The actual end-of-line style used in the archive entries doesn't
matter to unzip -a, as it converts any CR, CRLF and LF to the line end
characters appropriate for the platform it is running on.

Suggested-by: Ulrike Fischer <luatex@nililand.de>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archive-zip.c
t/t5003-archive-zip.sh