summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 767cf45)
raw | patch | inline | side by side (parent: 767cf45)
author | Jeff King <peff@peff.net> | |
Wed, 22 Jun 2011 01:27:35 +0000 (21:27 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 22 Jun 2011 18:12:35 +0000 (11:12 -0700) |
This works exactly as if the user had configured it via:
[tar "tgz"]
command = gzip -cn
[tar "tar.gz"]
command = gzip -cn
but since it is so common, it's convenient to have it
builtin without the user needing to do anything.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
[tar "tgz"]
command = gzip -cn
[tar "tar.gz"]
command = gzip -cn
but since it is so common, it's convenient to have it
builtin without the user needing to do anything.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-archive.txt | patch | blob | history | |
archive-tar.c | patch | blob | history | |
t/t5000-tar-tree.sh | patch | blob | history |
index 726bf63d460121ac06e480806e1915b0733b294d..8b0080a97759314e7b5f9c0c404c4e7d4af0a401 100644 (file)
to the command (e.g., "-9"). An output file with the same
extension as `<format>` will be use this format if no other
format is given.
++
+The "tar.gz" and "tgz" formats are defined automatically and default to
+`gzip -cn`. You may override them with custom commands.
ATTRIBUTES
----------
Create a compressed tarball for v1.4.0 release.
+git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz::
+
+ Same as above, but using the builtin tar.gz handling.
+
+git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0::
+
+ Same as above, but the format is inferred from the output file.
+
git archive --format=tar --prefix=git-1.4.0/ v1.4.0{caret}\{tree\} | gzip >git-1.4.0.tar.gz::
Create a compressed tarball for v1.4.0 release, but without a
diff --git a/archive-tar.c b/archive-tar.c
index 5c30747f9cf9be69a6829cc78367c908a99fa4dd..f470ebea1240dd48c6b34e88912a1f24137d3742 100644 (file)
--- a/archive-tar.c
+++ b/archive-tar.c
int i;
register_archiver(&tar_archiver);
+ tar_filter_config("tar.tgz.command", "gzip -cn", NULL);
+ tar_filter_config("tar.tar.gz.command", "gzip -cn", NULL);
git_config(git_tar_config, NULL);
for (i = 0; i < nr_tar_filters; i++) {
/* omit any filters that never had a command configured */
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 1f9069213aacb80fcf29fc87d89cefee7ae40fef..070250ebb0cb2b59560e63a56847dcd947b0d54a 100755 (executable)
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
. ./test-lib.sh
UNZIP=${UNZIP:-unzip}
+GZIP=${GZIP:-gzip}
+GUNZIP=${GUNZIP:-gzip -d}
SUBSTFORMAT=%H%n
test_cmp b.tar config-implicittar.foo
'
+if $GZIP --version >/dev/null 2>&1; then
+ test_set_prereq GZIP
+else
+ say "Skipping some tar.gz tests because gzip not found"
+fi
+
+test_expect_success GZIP 'git archive --format=tgz' '
+ git archive --format=tgz HEAD >j.tgz
+'
+
+test_expect_success GZIP 'git archive --format=tar.gz' '
+ git archive --format=tar.gz HEAD >j1.tar.gz &&
+ test_cmp j.tgz j1.tar.gz
+'
+
+test_expect_success GZIP 'infer tgz from .tgz filename' '
+ git archive --output=j2.tgz HEAD &&
+ test_cmp j.tgz j2.tgz
+'
+
+test_expect_success GZIP 'infer tgz from .tar.gz filename' '
+ git archive --output=j3.tar.gz HEAD &&
+ test_cmp j.tgz j3.tar.gz
+'
+
+if $GUNZIP --version >/dev/null 2>&1; then
+ test_set_prereq GUNZIP
+else
+ say "Skipping some tar.gz tests because gunzip was not found"
+fi
+
+test_expect_success GZIP,GUNZIP 'extract tgz file' '
+ $GUNZIP -c <j.tgz >j.tar &&
+ test_cmp b.tar j.tar
+'
+
test_done