Skip to content

Commit b1e4e17

Browse files
committed
Merge branch 'jk/archive-zip-userdiff-config' into maint
"git archive" did not read the standard configuration files, and failed to notice a file that is marked as binary via the userdiff driver configuration. * jk/archive-zip-userdiff-config: archive-zip: load userdiff config
2 parents 8103717 + 965cba2 commit b1e4e17

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

archive-zip.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,18 @@ static void dos_time(time_t *time, int *dos_date, int *dos_time)
554554
*dos_time = t->tm_sec / 2 + t->tm_min * 32 + t->tm_hour * 2048;
555555
}
556556

557+
static int archive_zip_config(const char *var, const char *value, void *data)
558+
{
559+
return userdiff_config(var, value);
560+
}
561+
557562
static int write_zip_archive(const struct archiver *ar,
558563
struct archiver_args *args)
559564
{
560565
int err;
561566

567+
git_config(archive_zip_config, NULL);
568+
562569
dos_time(&args->time, &zip_date, &zip_time);
563570

564571
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);

t/t5003-archive-zip.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ check_zip() {
6464
test_cmp_bin $original/nodiff.crlf $extracted/nodiff.crlf &&
6565
test_cmp_bin $original/nodiff.lf $extracted/nodiff.lf
6666
"
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+
"
6773
}
6874

6975
test_expect_success \
@@ -78,6 +84,9 @@ test_expect_success \
7884
printf "text\r" >a/nodiff.cr &&
7985
printf "text\r\n" >a/nodiff.crlf &&
8086
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 &&
8190
printf "\0\r" >a/binary.cr &&
8291
printf "\0\r\n" >a/binary.crlf &&
8392
printf "\0\n" >a/binary.lf &&
@@ -112,15 +121,20 @@ test_expect_success 'add files to repository' '
112121
test_expect_success 'setup export-subst and diff attributes' '
113122
echo "a/nodiff.* -diff" >>.git/info/attributes &&
114123
echo "a/diff.* diff" >>.git/info/attributes &&
124+
echo "a/custom.* diff=custom" >>.git/info/attributes &&
125+
git config diff.custom.binary true &&
115126
echo "substfile?" export-subst >>.git/info/attributes &&
116127
git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
117128
>a/substfile1
118129
'
119130

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+
'
124138

125139
test_expect_success \
126140
'remove ignored file' \

0 commit comments

Comments
 (0)