* [PATCH 1/4] t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead
2013-01-06 17:45 ` [PATCH 0/4] ZIP test fixes René Scharfe
@ 2013-01-06 17:47 ` René Scharfe
2013-01-07 5:16 ` Jonathan Nieder
2013-01-06 17:49 ` [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP René Scharfe
` (2 subsequent siblings)
3 siblings, 1 reply; 23+ messages in thread
From: René Scharfe @ 2013-01-06 17:47 UTC (permalink / raw)
To: git discussion list; +Cc: Junio C Hamano
InfoZIP's unzip takes default parameters from the environment variable
UNZIP. Unset it in the test library and use GIT_UNZIP for specifying
alternate versions of the unzip command instead.
t0024 wasn't even using variable for the actual extraction. t5000
was, but when setting it to InfoZIP's unzip it would try to extract
from itself (because it treats the contents of $UNZIP as parameters),
which failed of course.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
t/t0024-crlf-archive.sh | 6 +++---
t/t5000-tar-tree.sh | 10 +++++-----
t/test-lib.sh | 2 ++
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh
index ec6c1b3..080fe5c 100755
--- a/t/t0024-crlf-archive.sh
+++ b/t/t0024-crlf-archive.sh
@@ -3,7 +3,7 @@
test_description='respect crlf in git archive'
. ./test-lib.sh
-UNZIP=${UNZIP:-unzip}
+GIT_UNZIP=${GIT_UNZIP:-unzip}
test_expect_success setup '
@@ -26,7 +26,7 @@ test_expect_success 'tar archive' '
'
-"$UNZIP" -v >/dev/null 2>&1
+"$GIT_UNZIP" -v >/dev/null 2>&1
if [ $? -eq 127 ]; then
say "Skipping ZIP test, because unzip was not found"
else
@@ -37,7 +37,7 @@ test_expect_success UNZIP 'zip archive' '
git archive --format=zip HEAD >test.zip &&
- ( mkdir unzipped && cd unzipped && unzip ../test.zip ) &&
+ ( mkdir unzipped && cd unzipped && "$GIT_UNZIP" ../test.zip ) &&
test_cmp sample unzipped/sample
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index ecf00ed..1f7593d 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -25,7 +25,7 @@ commit id embedding:
'
. ./test-lib.sh
-UNZIP=${UNZIP:-unzip}
+GIT_UNZIP=${GIT_UNZIP:-unzip}
GZIP=${GZIP:-gzip}
GUNZIP=${GUNZIP:-gzip -d}
@@ -37,9 +37,9 @@ check_zip() {
dir=$1
dir_with_prefix=$dir/$2
- test_expect_success UNZIP " extract ZIP archive" "
- (mkdir $dir && cd $dir && $UNZIP ../$zipfile)
- "
+ test_expect_success UNZIP " extract ZIP archive" '
+ (mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
+ '
test_expect_success UNZIP " validate filenames" "
(cd ${dir_with_prefix}a && find .) | sort >$listfile &&
@@ -201,7 +201,7 @@ test_expect_success \
test_cmp a/substfile2 g/prefix/a/substfile2
'
-$UNZIP -v >/dev/null 2>&1
+"$GIT_UNZIP" -v >/dev/null 2>&1
if [ $? -eq 127 ]; then
say "Skipping ZIP tests, because unzip was not found"
else
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 8a12cbb..d8ec408 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -85,6 +85,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
.*_TEST
PROVE
VALGRIND
+ UNZIP
PERF_AGGREGATING_LATER
));
my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
@@ -128,6 +129,7 @@ fi
unset CDPATH
unset GREP_OPTIONS
+unset UNZIP
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
1|2|true)
--
1.7.12
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead
2013-01-06 17:47 ` [PATCH 1/4] t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead René Scharfe
@ 2013-01-07 5:16 ` Jonathan Nieder
2013-01-07 16:25 ` René Scharfe
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Nieder @ 2013-01-07 5:16 UTC (permalink / raw)
To: René Scharfe; +Cc: git discussion list, Junio C Hamano
René Scharfe wrote:
> InfoZIP's unzip takes default parameters from the environment variable
> UNZIP. Unset it in the test library and use GIT_UNZIP for specifying
> alternate versions of the unzip command instead.
>
> t0024 wasn't even using variable for the actual extraction. t5000
> was, but when setting it to InfoZIP's unzip it would try to extract
> from itself (because it treats the contents of $UNZIP as parameters),
> which failed of course.
That would only happen if the UNZIP variable was already exported,
right?
The patch makes sense and takes care of all uses of ${UNZIP} I can
find, and it even makes the quoting consistent so a person can put
their copy of unzip under "/Program Files". For what it's worth,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/4] t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead
2013-01-07 5:16 ` Jonathan Nieder
@ 2013-01-07 16:25 ` René Scharfe
0 siblings, 0 replies; 23+ messages in thread
From: René Scharfe @ 2013-01-07 16:25 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git discussion list, Junio C Hamano
Am 07.01.2013 06:16, schrieb Jonathan Nieder:
> René Scharfe wrote:
>
>> InfoZIP's unzip takes default parameters from the environment variable
>> UNZIP. Unset it in the test library and use GIT_UNZIP for specifying
>> alternate versions of the unzip command instead.
>>
>> t0024 wasn't even using variable for the actual extraction. t5000
>> was, but when setting it to InfoZIP's unzip it would try to extract
>> from itself (because it treats the contents of $UNZIP as parameters),
>> which failed of course.
>
> That would only happen if the UNZIP variable was already exported,
> right?
We don't want any parameters a user may have been specified influence
the test. I'm not sure if someone actually sets that variable for that
purpose, though.
My main use case is running individual test scripts with an alternative
unzip binary, and with the patch this works as expected:
$ cd t
$ GIT_UNZIP=/usr/pkg/bin/unzip ./t5000-tar-tree.sh
> The patch makes sense and takes care of all uses of ${UNZIP} I can
> find, and it even makes the quoting consistent so a person can put
> their copy of unzip under "/Program Files". For what it's worth,
>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks!
René
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP
2013-01-06 17:45 ` [PATCH 0/4] ZIP test fixes René Scharfe
2013-01-06 17:47 ` [PATCH 1/4] t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead René Scharfe
@ 2013-01-06 17:49 ` René Scharfe
2013-01-06 18:06 ` Matt Kraai
2013-01-07 8:45 ` Jonathan Nieder
2013-01-06 17:51 ` [PATCH 3/4] t5000, t5002: move ZIP tests into their own script René Scharfe
2013-01-06 17:59 ` [PATCH 4/4] t5002: check if unzip supports symlinks René Scharfe
3 siblings, 2 replies; 23+ messages in thread
From: René Scharfe @ 2013-01-06 17:49 UTC (permalink / raw)
To: git discussion list; +Cc: Junio C Hamano
This change makes the code smaller and we can put it at the top of
the script, its rightful place as setup code.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
t/t0024-crlf-archive.sh | 12 +++++-------
t/t5000-tar-tree.sh | 12 +++++-------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh
index 080fe5c..ba397bb 100755
--- a/t/t0024-crlf-archive.sh
+++ b/t/t0024-crlf-archive.sh
@@ -5,6 +5,11 @@ test_description='respect crlf in git archive'
. ./test-lib.sh
GIT_UNZIP=${GIT_UNZIP:-unzip}
+test_lazy_prereq UNZIP '
+ "$GIT_UNZIP" -v >/dev/null 2>&1
+ test $? -ne 127
+'
+
test_expect_success setup '
git config core.autocrlf true &&
@@ -26,13 +31,6 @@ test_expect_success 'tar archive' '
'
-"$GIT_UNZIP" -v >/dev/null 2>&1
-if [ $? -eq 127 ]; then
- say "Skipping ZIP test, because unzip was not found"
-else
- test_set_prereq UNZIP
-fi
-
test_expect_success UNZIP 'zip archive' '
git archive --format=zip HEAD >test.zip &&
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 1f7593d..6702157 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -31,6 +31,11 @@ GUNZIP=${GUNZIP:-gzip -d}
SUBSTFORMAT=%H%n
+test_lazy_prereq UNZIP '
+ "$GIT_UNZIP" -v >/dev/null 2>&1
+ test $? -ne 127
+'
+
check_zip() {
zipfile=$1.zip
listfile=$1.lst
@@ -201,13 +206,6 @@ test_expect_success \
test_cmp a/substfile2 g/prefix/a/substfile2
'
-"$GIT_UNZIP" -v >/dev/null 2>&1
-if [ $? -eq 127 ]; then
- say "Skipping ZIP tests, because unzip was not found"
-else
- test_set_prereq UNZIP
-fi
-
test_expect_success \
'git archive --format=zip' \
'git archive --format=zip HEAD >d.zip'
--
1.7.12
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP
2013-01-06 17:49 ` [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP René Scharfe
@ 2013-01-06 18:06 ` Matt Kraai
2013-01-06 21:59 ` René Scharfe
2013-01-07 8:45 ` Jonathan Nieder
1 sibling, 1 reply; 23+ messages in thread
From: Matt Kraai @ 2013-01-06 18:06 UTC (permalink / raw)
To: René Scharfe; +Cc: git discussion list, Junio C Hamano
On Sun, Jan 06, 2013 at 06:49:00PM +0100, René Scharfe wrote:
> This change makes the code smaller and we can put it at the top of
> the script, its rightful place as setup code.
Would it be better to add the setting of GIT_UNZIP and
test_lazy_prereq to test-lib.sh so they aren't duplicated in both
t0024-crlf-archive.sh and t5000-tar-tree.sh, something like the
following (modulo UNZIP/GIT_UNZIP)?
--
Matt Kraai
https://ftbfs.org/kraai
diff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh
index ec6c1b3..084f33c 100755
--- a/t/t0024-crlf-archive.sh
+++ b/t/t0024-crlf-archive.sh
@@ -3,7 +3,6 @@
test_description='respect crlf in git archive'
. ./test-lib.sh
-UNZIP=${UNZIP:-unzip}
test_expect_success setup '
@@ -26,13 +25,6 @@ test_expect_success 'tar archive' '
'
-"$UNZIP" -v >/dev/null 2>&1
-if [ $? -eq 127 ]; then
- say "Skipping ZIP test, because unzip was not found"
-else
- test_set_prereq UNZIP
-fi
-
test_expect_success UNZIP 'zip archive' '
git archive --format=zip HEAD >test.zip &&
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index ecf00ed..85b64ae 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -25,7 +25,6 @@ commit id embedding:
'
. ./test-lib.sh
-UNZIP=${UNZIP:-unzip}
GZIP=${GZIP:-gzip}
GUNZIP=${GUNZIP:-gzip -d}
@@ -201,13 +200,6 @@ test_expect_success \
test_cmp a/substfile2 g/prefix/a/substfile2
'
-$UNZIP -v >/dev/null 2>&1
-if [ $? -eq 127 ]; then
- say "Skipping ZIP tests, because unzip was not found"
-else
- test_set_prereq UNZIP
-fi
-
test_expect_success \
'git archive --format=zip' \
'git archive --format=zip HEAD >d.zip'
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 8a12cbb..4ceabad 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -752,6 +752,13 @@ test_lazy_prereq AUTOIDENT '
git var GIT_AUTHOR_IDENT
'
+UNZIP=${UNZIP:-unzip}
+
+test_lazy_prereq UNZIP '
+ "$UNZIP" -v >/dev/null 2>&1
+ test $? -ne 127
+'
+
# When the tests are run as root, permission tests will report that
# things are writable when they shouldn't be.
test -w / || test_set_prereq SANITY
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP
2013-01-06 18:06 ` Matt Kraai
@ 2013-01-06 21:59 ` René Scharfe
0 siblings, 0 replies; 23+ messages in thread
From: René Scharfe @ 2013-01-06 21:59 UTC (permalink / raw)
To: git discussion list, Junio C Hamano
Am 06.01.2013 19:06, schrieb Matt Kraai:
> On Sun, Jan 06, 2013 at 06:49:00PM +0100, René Scharfe wrote:
>> This change makes the code smaller and we can put it at the top of
>> the script, its rightful place as setup code.
>
> Would it be better to add the setting of GIT_UNZIP and
> test_lazy_prereq to test-lib.sh so they aren't duplicated in both
> t0024-crlf-archive.sh and t5000-tar-tree.sh, something like the
> following (modulo UNZIP/GIT_UNZIP)?
We could do that in a follow-up patch, but I'm not sure it's worth it
for the two use cases.
René
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP
2013-01-06 17:49 ` [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP René Scharfe
2013-01-06 18:06 ` Matt Kraai
@ 2013-01-07 8:45 ` Jonathan Nieder
2013-01-07 16:28 ` René Scharfe
1 sibling, 1 reply; 23+ messages in thread
From: Jonathan Nieder @ 2013-01-07 8:45 UTC (permalink / raw)
To: René Scharfe; +Cc: git discussion list, Junio C Hamano
René Scharfe wrote:
> --- a/t/t0024-crlf-archive.sh
> +++ b/t/t0024-crlf-archive.sh
> @@ -5,6 +5,11 @@ test_description='respect crlf in git archive'
> . ./test-lib.sh
> GIT_UNZIP=${GIT_UNZIP:-unzip}
>
> +test_lazy_prereq UNZIP '
> + "$GIT_UNZIP" -v >/dev/null 2>&1
> + test $? -ne 127
Micronit: now that this is part of a test, there is no more need to
silence its output. The "unzip -v" output could be useful to people
debugging with "t0024-crlf-archive.sh -v -i".
With or without that change, this is a nice cleanup and obviously
correct, so
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP
2013-01-07 8:45 ` Jonathan Nieder
@ 2013-01-07 16:28 ` René Scharfe
0 siblings, 0 replies; 23+ messages in thread
From: René Scharfe @ 2013-01-07 16:28 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git discussion list, Junio C Hamano
Am 07.01.2013 09:45, schrieb Jonathan Nieder:
> René Scharfe wrote:
>
>> --- a/t/t0024-crlf-archive.sh
>> +++ b/t/t0024-crlf-archive.sh
>> @@ -5,6 +5,11 @@ test_description='respect crlf in git archive'
>> . ./test-lib.sh
>> GIT_UNZIP=${GIT_UNZIP:-unzip}
>>
>> +test_lazy_prereq UNZIP '
>> + "$GIT_UNZIP" -v >/dev/null 2>&1
>> + test $? -ne 127
>
> Micronit: now that this is part of a test, there is no more need to
> silence its output. The "unzip -v" output could be useful to people
> debugging with "t0024-crlf-archive.sh -v -i".
Oh, yes, good point.
> With or without that change, this is a nice cleanup and obviously
> correct, so
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks,
René
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 3/4] t5000, t5002: move ZIP tests into their own script
2013-01-06 17:45 ` [PATCH 0/4] ZIP test fixes René Scharfe
2013-01-06 17:47 ` [PATCH 1/4] t0024, t5000: clear variable UNZIP, use GIT_UNZIP instead René Scharfe
2013-01-06 17:49 ` [PATCH 2/4] t0024, t5000: use test_lazy_prereq for UNZIP René Scharfe
@ 2013-01-06 17:51 ` René Scharfe
2013-01-06 17:59 ` [PATCH 4/4] t5002: check if unzip supports symlinks René Scharfe
3 siblings, 0 replies; 23+ messages in thread
From: René Scharfe @ 2013-01-06 17:51 UTC (permalink / raw)
To: git discussion list; +Cc: Junio C Hamano
This makes ZIP specific tweaks easier.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
t/t5000-tar-tree.sh | 69 ----------------------------
t/t5002-archive-zip.sh | 119 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+), 69 deletions(-)
create mode 100755 t/t5002-archive-zip.sh
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 6702157..e7c240f 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -25,37 +25,11 @@ commit id embedding:
'
. ./test-lib.sh
-GIT_UNZIP=${GIT_UNZIP:-unzip}
GZIP=${GZIP:-gzip}
GUNZIP=${GUNZIP:-gzip -d}
SUBSTFORMAT=%H%n
-test_lazy_prereq UNZIP '
- "$GIT_UNZIP" -v >/dev/null 2>&1
- test $? -ne 127
-'
-
-check_zip() {
- zipfile=$1.zip
- listfile=$1.lst
- dir=$1
- dir_with_prefix=$dir/$2
-
- test_expect_success UNZIP " extract ZIP archive" '
- (mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
- '
-
- test_expect_success UNZIP " validate filenames" "
- (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
- test_cmp a.lst $listfile
- "
-
- test_expect_success UNZIP " validate file contents" "
- diff -r a ${dir_with_prefix}a
- "
-}
-
test_expect_success \
'populate workdir' \
'mkdir a b c &&
@@ -206,55 +180,12 @@ test_expect_success \
test_cmp a/substfile2 g/prefix/a/substfile2
'
-test_expect_success \
- 'git archive --format=zip' \
- 'git archive --format=zip HEAD >d.zip'
-
-check_zip d
-
-test_expect_success \
- 'git archive --format=zip in a bare repo' \
- '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
-
-test_expect_success \
- 'git archive --format=zip vs. the same in a bare repo' \
- 'test_cmp d.zip d1.zip'
-
-test_expect_success 'git archive --format=zip with --output' \
- 'git archive --format=zip --output=d2.zip HEAD &&
- test_cmp d.zip d2.zip'
-
-test_expect_success 'git archive with --output, inferring format' '
- git archive --output=d3.zip HEAD &&
- test_cmp d.zip d3.zip
-'
-
test_expect_success 'git archive with --output, override inferred format' '
git archive --format=tar --output=d4.zip HEAD &&
test_cmp b.tar d4.zip
'
test_expect_success \
- 'git archive --format=zip with prefix' \
- 'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
-
-check_zip e prefix/
-
-test_expect_success 'git archive -0 --format=zip on large files' '
- test_config core.bigfilethreshold 1 &&
- git archive -0 --format=zip HEAD >large.zip
-'
-
-check_zip large
-
-test_expect_success 'git archive --format=zip on large files' '
- test_config core.bigfilethreshold 1 &&
- git archive --format=zip HEAD >large-compressed.zip
-'
-
-check_zip large-compressed
-
-test_expect_success \
'git archive --list outside of a git repo' \
'GIT_DIR=some/non-existing/directory git archive --list'
diff --git a/t/t5002-archive-zip.sh b/t/t5002-archive-zip.sh
new file mode 100755
index 0000000..ac9c6d4
--- /dev/null
+++ b/t/t5002-archive-zip.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+test_description='git archive --format=zip test'
+
+. ./test-lib.sh
+GIT_UNZIP=${GIT_UNZIP:-unzip}
+
+SUBSTFORMAT=%H%n
+
+test_lazy_prereq UNZIP '
+ "$GIT_UNZIP" -v >/dev/null 2>&1
+ test $? -ne 127
+'
+
+check_zip() {
+ zipfile=$1.zip
+ listfile=$1.lst
+ dir=$1
+ dir_with_prefix=$dir/$2
+
+ test_expect_success UNZIP " extract ZIP archive" '
+ (mkdir $dir && cd $dir && "$GIT_UNZIP" ../$zipfile)
+ '
+
+ test_expect_success UNZIP " validate filenames" "
+ (cd ${dir_with_prefix}a && find .) | sort >$listfile &&
+ test_cmp a.lst $listfile
+ "
+
+ test_expect_success UNZIP " validate file contents" "
+ diff -r a ${dir_with_prefix}a
+ "
+}
+
+test_expect_success \
+ 'populate workdir' \
+ 'mkdir a b c &&
+ echo simple textfile >a/a &&
+ mkdir a/bin &&
+ cp /bin/sh a/bin &&
+ printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
+ printf "A not substituted O" >a/substfile2 &&
+ if test_have_prereq SYMLINKS; then
+ ln -s a a/l1
+ else
+ printf %s a > a/l1
+ fi &&
+ (p=long_path_to_a_file && cd a &&
+ for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
+ echo text >file_with_long_path) &&
+ (cd a && find .) | sort >a.lst'
+
+test_expect_success \
+ 'add ignored file' \
+ 'echo ignore me >a/ignored &&
+ echo ignored export-ignore >.git/info/attributes'
+
+test_expect_success \
+ 'add files to repository' \
+ 'find a -type f | xargs git update-index --add &&
+ find a -type l | xargs git update-index --add &&
+ treeid=`git write-tree` &&
+ echo $treeid >treeid &&
+ git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
+ git commit-tree $treeid </dev/null)'
+
+test_expect_success \
+ 'create bare clone' \
+ 'git clone --bare . bare.git &&
+ cp .git/info/attributes bare.git/info/attributes'
+
+test_expect_success \
+ 'remove ignored file' \
+ 'rm a/ignored'
+
+test_expect_success \
+ 'git archive --format=zip' \
+ 'git archive --format=zip HEAD >d.zip'
+
+check_zip d
+
+test_expect_success \
+ 'git archive --format=zip in a bare repo' \
+ '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
+
+test_expect_success \
+ 'git archive --format=zip vs. the same in a bare repo' \
+ 'test_cmp d.zip d1.zip'
+
+test_expect_success 'git archive --format=zip with --output' \
+ 'git archive --format=zip --output=d2.zip HEAD &&
+ test_cmp d.zip d2.zip'
+
+test_expect_success 'git archive with --output, inferring format' '
+ git archive --output=d3.zip HEAD &&
+ test_cmp d.zip d3.zip
+'
+
+test_expect_success \
+ 'git archive --format=zip with prefix' \
+ 'git archive --format=zip --prefix=prefix/ HEAD >e.zip'
+
+check_zip e prefix/
+
+test_expect_success 'git archive -0 --format=zip on large files' '
+ test_config core.bigfilethreshold 1 &&
+ git archive -0 --format=zip HEAD >large.zip
+'
+
+check_zip large
+
+test_expect_success 'git archive --format=zip on large files' '
+ test_config core.bigfilethreshold 1 &&
+ git archive --format=zip HEAD >large-compressed.zip
+'
+
+check_zip large-compressed
+
+test_done
--
1.7.12
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/4] t5002: check if unzip supports symlinks
2013-01-06 17:45 ` [PATCH 0/4] ZIP test fixes René Scharfe
` (2 preceding siblings ...)
2013-01-06 17:51 ` [PATCH 3/4] t5000, t5002: move ZIP tests into their own script René Scharfe
@ 2013-01-06 17:59 ` René Scharfe
2013-01-07 8:52 ` Jonathan Nieder
3 siblings, 1 reply; 23+ messages in thread
From: René Scharfe @ 2013-01-06 17:59 UTC (permalink / raw)
To: git discussion list; +Cc: Junio C Hamano
Only add a symlink to the repository if both the filesystem and
unzip support symlinks. To check the latter, add a ZIP file
containing a symlink, created like this with InfoZIP zip 3.0:
$ echo sample text >textfile
$ ln -s textfile symlink
$ zip -y infozip-symlinks.zip textfile symlink
If we can extract it successfully, we add a symlink to the test
repository for git archive --format=zip, or otherwise skip that
step. Users can see the skipped test and perhaps run it again
with a different unzip version.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
t/t5002-archive-zip.sh | 26 +++++++++++++++++++-------
t/t5002/infozip-symlinks.zip | Bin 0 -> 328 bytes
2 files changed, 19 insertions(+), 7 deletions(-)
create mode 100644 t/t5002/infozip-symlinks.zip
diff --git a/t/t5002-archive-zip.sh b/t/t5002-archive-zip.sh
index ac9c6d4..d35aa24 100755
--- a/t/t5002-archive-zip.sh
+++ b/t/t5002-archive-zip.sh
@@ -12,6 +12,15 @@ test_lazy_prereq UNZIP '
test $? -ne 127
'
+test_lazy_prereq UNZIP_SYMLINKS '
+ (
+ mkdir unzip-symlinks &&
+ cd unzip-symlinks &&
+ "$GIT_UNZIP" "$TEST_DIRECTORY"/t5002/infozip-symlinks.zip &&
+ test -h symlink
+ )
+'
+
check_zip() {
zipfile=$1.zip
listfile=$1.lst
@@ -40,15 +49,18 @@ test_expect_success \
cp /bin/sh a/bin &&
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
printf "A not substituted O" >a/substfile2 &&
- if test_have_prereq SYMLINKS; then
- ln -s a a/l1
- else
- printf %s a > a/l1
- fi &&
(p=long_path_to_a_file && cd a &&
for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
- echo text >file_with_long_path) &&
- (cd a && find .) | sort >a.lst'
+ echo text >file_with_long_path)
+'
+
+test_expect_success SYMLINKS,UNZIP_SYMLINKS 'add symlink' '
+ ln -s a a/symlink_to_a
+'
+
+test_expect_success 'prepare file list' '
+ (cd a && find .) | sort >a.lst
+'
test_expect_success \
'add ignored file' \
diff --git a/t/t5002/infozip-symlinks.zip b/t/t5002/infozip-symlinks.zip
new file mode 100644
index 0000000000000000000000000000000000000000..065728c631cf1f7ab20a045a83abc3e08455eeba
GIT binary patch
literal 328
zcmWIWW@h1H0D(ty)tzkeJdg4K*&xipAj43ST2YdgnUfkC!pXp_F7Y}5gi9;985mh!
zFf%Z)qyW_wC*~I9q$+@vas|Lmdj&M@9kbsh4zNiK4D3MDiYs$-GV`**hM5Bm0%0`6
zU={{=Gcw6B<8qh;&`<^jMj&3&2x7r>g@&*~oQY;CvT2wOgO~;~=j}p2APILS&@e1c
U4De=U11V+#!r4H2I*7vn0CeC%rvLx|
literal 0
HcmV?d00001
--
1.7.12
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 4/4] t5002: check if unzip supports symlinks
2013-01-06 17:59 ` [PATCH 4/4] t5002: check if unzip supports symlinks René Scharfe
@ 2013-01-07 8:52 ` Jonathan Nieder
2013-01-07 16:50 ` René Scharfe
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Nieder @ 2013-01-07 8:52 UTC (permalink / raw)
To: René Scharfe; +Cc: git discussion list, Junio C Hamano
René Scharfe wrote:
> Only add a symlink to the repository if both the filesystem and
> unzip support symlinks. To check the latter, add a ZIP file
> containing a symlink, created like this with InfoZIP zip 3.0:
>
> $ echo sample text >textfile
> $ ln -s textfile symlink
> $ zip -y infozip-symlinks.zip textfile symlink
Hm. Do some implementations of "unzip" not support symlinks, or is
the problem that some systems build Info-ZIP without the SYMLINKS
option?
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/4] t5002: check if unzip supports symlinks
2013-01-07 8:52 ` Jonathan Nieder
@ 2013-01-07 16:50 ` René Scharfe
2013-01-10 7:36 ` Jonathan Nieder
0 siblings, 1 reply; 23+ messages in thread
From: René Scharfe @ 2013-01-07 16:50 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git discussion list, Junio C Hamano
Am 07.01.2013 09:52, schrieb Jonathan Nieder:
> René Scharfe wrote:
>
>> Only add a symlink to the repository if both the filesystem and
>> unzip support symlinks. To check the latter, add a ZIP file
>> containing a symlink, created like this with InfoZIP zip 3.0:
>>
>> $ echo sample text >textfile
>> $ ln -s textfile symlink
>> $ zip -y infozip-symlinks.zip textfile symlink
>
> Hm. Do some implementations of "unzip" not support symlinks, or is
> the problem that some systems build Info-ZIP without the SYMLINKS
> option?
The unzip supplied with NetBSD 6.0.1, which is based on libarchive,
doesn't support symlinks. It creates a file with the link target path
as its only content for such entries.
I assume that Info-ZIP is compiled with the SYMLINKS option on all
platforms whose default filesystem supports symbolic links. Except on
Windows perhaps, where it's complicated.
For the test script there is no difference: If we don't have a tool to
verify symlinks in archives, we better skip that part.
René
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/4] t5002: check if unzip supports symlinks
2013-01-07 16:50 ` René Scharfe
@ 2013-01-10 7:36 ` Jonathan Nieder
0 siblings, 0 replies; 23+ messages in thread
From: Jonathan Nieder @ 2013-01-10 7:36 UTC (permalink / raw)
To: René Scharfe; +Cc: git discussion list, Junio C Hamano
René Scharfe wrote:
> Am 07.01.2013 09:52, schrieb Jonathan Nieder:
>> Hm. Do some implementations of "unzip" not support symlinks, or is
>> the problem that some systems build Info-ZIP without the SYMLINKS
>> option?
>
> The unzip supplied with NetBSD 6.0.1, which is based on libarchive, doesn't
> support symlinks. It creates a file with the link target path as its only
> content for such entries.
Ok, that makes sense. A quick search finds
<https://code.google.com/p/libarchive/issues/detail?id=104>, which if
I understand correctly was fixed in libarchive 3.0.2. NetBSD 6 uses a
patched 2.8.4.
[...]
> For the test script there is no difference: If we don't have a tool to
> verify symlinks in archives, we better skip that part.
Yeah, I just wanted to see if there were other parts of the world that
needed fixing while at it. Thanks for explaining.
Ciao,
Jonathan
^ permalink raw reply [flat|nested] 23+ messages in thread