archive-zip: load userdiff config
Since 4aff646d17 (archive-zip: mark text files in archives, 2015-03-05), the zip archiver will look at the userdiff driver to decide whether a file is text or binary. This usually doesn't need to look any further than the attributes themselves (e.g., "-diff", etc). But if the user defines a custom driver like "diff=foo", we need to look at "diff.foo.binary" in the config. Prior to this patch, we didn't actually load it. Signed-off-by: Jeff King <peff@peff.net> Acked-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 2, 2017 at 17:25 UTC
965cba2e7ee9b272a35d66a11f0a7bf544aa727a
2 files changed
+25
-4
archive-zip.c
+7
@@ -554,11 +554,18 @@ static void dos_time(time_t *time, int *dos_date, int *dos_time)
554
*dos_time = t->tm_sec / 2 + t->tm_min * 32 + t->tm_hour * 2048;
555
}
556
557
+static int archive_zip_config(const char *var, const char *value, void *data)
558
+{
559
+ return userdiff_config(var, value);
560
+}
561
+
562
static int write_zip_archive(const struct archiver *ar,
563
struct archiver_args *args)
564
{
565
int err;
566
567
+ git_config(archive_zip_config, NULL);
568
+
569
dos_time(&args->time, &zip_date, &zip_time);
570
571
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
t/t5003-archive-zip.sh
+18
-4
@@ -64,6 +64,12 @@ check_zip() {
64
test_cmp_bin $original/nodiff.crlf $extracted/nodiff.crlf &&
65
test_cmp_bin $original/nodiff.lf $extracted/nodiff.lf
66
"
67
+
68
+ test_expect_success UNZIP " validate that custom diff is unchanged " "
69
+ test_cmp_bin $original/custom.cr $extracted/custom.cr &&
70
+ test_cmp_bin $original/custom.crlf $extracted/custom.crlf &&
71
+ test_cmp_bin $original/custom.lf $extracted/custom.lf
72
+ "
73
}
74
75
test_expect_success \
@@ -78,6 +84,9 @@ test_expect_success \
84
printf "text\r" >a/nodiff.cr &&
85
printf "text\r\n" >a/nodiff.crlf &&
86
printf "text\n" >a/nodiff.lf &&
87
+ printf "text\r" >a/custom.cr &&
88
+ printf "text\r\n" >a/custom.crlf &&
89
+ printf "text\n" >a/custom.lf &&
90
printf "\0\r" >a/binary.cr &&
91
printf "\0\r\n" >a/binary.crlf &&
92
printf "\0\n" >a/binary.lf &&
@@ -112,15 +121,20 @@ test_expect_success 'add files to repository' '
121
test_expect_success 'setup export-subst and diff attributes' '
122
echo "a/nodiff.* -diff" >>.git/info/attributes &&
123
echo "a/diff.* diff" >>.git/info/attributes &&
124
+ echo "a/custom.* diff=custom" >>.git/info/attributes &&
125
+ git config diff.custom.binary true &&
126
echo "substfile?" export-subst >>.git/info/attributes &&
127
git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
128
>a/substfile1
129
'
130
120
-test_expect_success \
121
- 'create bare clone' \
122
- 'git clone --bare . bare.git &&
123
- cp .git/info/attributes bare.git/info/attributes'
131
+test_expect_success 'create bare clone' '
132
+ git clone --bare . bare.git &&
133
+ cp .git/info/attributes bare.git/info/attributes &&
134
+ # Recreate our changes to .git/config rather than just copying it, as
135
+ # we do not want to clobber core.bare or other settings.
136
+ git -C bare.git config diff.custom.binary true
137
+'
138
139
test_expect_success \
140
'remove ignored file' \