summaryrefslogtreecommitdiff
path: root/t/t5003-archive-zip.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5003-archive-zip.sh')
-rwxr-xr-xt/t5003-archive-zip.sh89
1 files changed, 87 insertions, 2 deletions
diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh
index 3b76d2e..961c6aa 100755
--- a/t/t5003-archive-zip.sh
+++ b/t/t5003-archive-zip.sh
@@ -2,6 +2,7 @@
test_description='git archive --format=zip test'
+TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh
SUBSTFORMAT=%H%n
@@ -72,6 +73,16 @@ check_zip() {
"
}
+check_added() {
+ dir=$1
+ path_in_fs=$2
+ path_in_archive=$3
+
+ test_expect_success UNZIP " validate extra file $path_in_archive" '
+ diff -r $path_in_fs $dir/$path_in_archive
+ '
+}
+
test_expect_success \
'populate workdir' \
'mkdir a &&
@@ -96,7 +107,7 @@ test_expect_success \
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
printf "A not substituted O" >a/substfile2 &&
(p=long_path_to_a_file && cd a &&
- for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
+ for depth in 1 2 3 4 5; do mkdir $p && cd $p || exit 1; done &&
echo text >file_with_long_path)
'
@@ -111,6 +122,7 @@ test_expect_success 'prepare file list' '
test_expect_success \
'add ignored file' \
'echo ignore me >a/ignored &&
+ mkdir .git/info &&
echo ignored export-ignore >.git/info/attributes'
test_expect_success 'add files to repository' '
@@ -129,7 +141,8 @@ test_expect_success 'setup export-subst and diff attributes' '
'
test_expect_success 'create bare clone' '
- git clone --bare . bare.git &&
+ git clone --template= --bare . bare.git &&
+ mkdir bare.git/info &&
cp .git/info/attributes bare.git/info/attributes &&
# Recreate our changes to .git/config rather than just copying it, as
# we do not want to clobber core.bare or other settings.
@@ -188,4 +201,76 @@ test_expect_success 'git archive --format=zip on large files' '
check_zip large-compressed
+test_expect_success 'git archive --format=zip --add-file' '
+ echo untracked >untracked &&
+ git archive --format=zip --add-file=untracked HEAD >with_untracked.zip
+'
+
+check_zip with_untracked
+check_added with_untracked untracked untracked
+
+test_expect_success UNZIP 'git archive --format=zip --add-virtual-file' '
+ if test_have_prereq FUNNYNAMES
+ then
+ PATHNAME="pathname with : colon"
+ else
+ PATHNAME="pathname without colon"
+ fi &&
+ git archive --format=zip >with_file_with_content.zip \
+ --add-virtual-file=\""$PATHNAME"\": \
+ --add-virtual-file=hello:world $EMPTY_TREE &&
+ test_when_finished "rm -rf tmp-unpack" &&
+ mkdir tmp-unpack && (
+ cd tmp-unpack &&
+ "$GIT_UNZIP" ../with_file_with_content.zip &&
+ test_path_is_file hello &&
+ test_path_is_file "$PATHNAME" &&
+ test world = $(cat hello)
+ )
+'
+
+test_expect_success 'git archive --format=zip --add-file twice' '
+ echo untracked >untracked &&
+ git archive --format=zip --prefix=one/ --add-file=untracked \
+ --prefix=two/ --add-file=untracked \
+ --prefix= HEAD >with_untracked2.zip
+'
+check_zip with_untracked2
+check_added with_untracked2 untracked one/untracked
+check_added with_untracked2 untracked two/untracked
+
+# Test remote archive over HTTP protocol.
+#
+# Note: this should be the last part of this test suite, because
+# by including lib-httpd.sh, the test may end early if httpd tests
+# should not be run.
+#
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success "setup for HTTP protocol" '
+ cp -R bare.git "$HTTPD_DOCUMENT_ROOT_PATH/bare.git" &&
+ git -C "$HTTPD_DOCUMENT_ROOT_PATH/bare.git" \
+ config http.uploadpack true &&
+ set_askpass user@host pass@host
+'
+
+setup_askpass_helper
+
+test_expect_success 'remote archive does not work with protocol v1' '
+ test_must_fail git -c protocol.version=1 archive \
+ --remote="$HTTPD_URL/auth/smart/bare.git" \
+ --output=remote-http.zip HEAD >actual 2>&1 &&
+ cat >expect <<-EOF &&
+ fatal: can${SQ}t connect to subservice git-upload-archive
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'archive remote http repository' '
+ git archive --remote="$HTTPD_URL/auth/smart/bare.git" \
+ --output=remote-http.zip HEAD &&
+ test_cmp_bin d.zip remote-http.zip
+'
+
test_done