git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: git@vger.kernel.org
Cc: "René Scharfe" <l.s.r@web.de>, "Jeff King" <peff@peff.net>,
	"Bagas Sanjaya" <bagasdotme@gmail.com>
Subject: [PATCH] archive: add test testing MIME for created archive through compression filter
Date: Mon, 11 Oct 2021 18:27:13 +0700	[thread overview]
Message-ID: <20211011112712.475306-1-bagasdotme@gmail.com> (raw)

The common use of `tar.<format>.command` config is to specify
compression program filter for creating compressed tar archive.

Add a test that tests MIME type of archives created through the filter.
The generated archives must not be `application/x-tar` (POSIX tar
archive) type, so that these can be decompressed with the corresponding
decompression program (such as gunzip, bunzip2, and unxz).

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 t/t5000-tar-tree.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 2c88d1c159..04cdad5bff 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -38,6 +38,8 @@ test_lazy_prereq TAR_NEEDS_PAX_FALLBACK '
 '
 
 test_lazy_prereq GZIP 'gzip --version'
+test_lazy_prereq BZIP2 'bzip2 --version'
+test_lazy_prereq XZ 'xz --version'
 
 get_pax_header() {
 	file=$1
@@ -374,6 +376,21 @@ test_expect_success GZIP 'remote tar.gz can be disabled' '
 		>remote.tar.gz
 '
 
+test_expect_success GZIP,BZIP2,XZ 'git archive with gzip, bzip2, and xz filters creates compressed tar archive with proper MIME type' '
+	git config tar.tar.bz2.command "bzip2 -c" &&
+	git config tar.tar.xz.command "xz -c" &&
+	git archive --output HEAD.tar.gz --prefix=src/ HEAD &&
+	git archive --output HEAD.tar.bz2 --prefix=src/ HEAD &&
+	git archive --output HEAD.tar.xz --prefix=src/ HEAD &&
+	cat >expect <<EOF &&
+HEAD.tar.bz2: application/x-bzip2; charset=binary
+HEAD.tar.gz:  application/gzip; charset=binary
+HEAD.tar.xz:  application/x-xz; charset=binary
+EOF
+	file -i HEAD.tar.bz2 HEAD.tar.gz HEAD.tar.xz 2>/dev/null >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'archive and :(glob)' '
 	git archive -v HEAD -- ":(glob)**/sh" >/dev/null 2>actual &&
 	cat >expect <<EOF &&

base-commit: 106298f7f9cca4158a980de149ef217751e1f943
-- 
An old man doll... just what I always wanted! - Clara


             reply	other threads:[~2021-10-11 11:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 11:27 Bagas Sanjaya [this message]
2021-10-11 15:48 ` [PATCH] archive: add test testing MIME for created archive through compression filter Junio C Hamano
2021-10-11 15:53 ` Junio C Hamano
2021-10-11 16:07   ` Jeff King
2021-10-12  3:14   ` Bagas Sanjaya
2021-10-12 19:15     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211011112712.475306-1-bagasdotme@gmail.com \
    --to=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).