]> git.ipfire.org Git - thirdparty/git.git/commitdiff
archive-tar: use internal gzip by default
authorRené Scharfe <l.s.r@web.de>
Wed, 15 Jun 2022 17:05:03 +0000 (19:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jun 2022 20:19:47 +0000 (13:19 -0700)
Drop the dependency on gzip(1) and use our internal implementation to
create tar.gz and tgz files.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-archive.txt
archive-tar.c
t/t5000-tar-tree.sh

index b2d1b63d310d76236718193a0e88fcecf301fc0e..60c040988bb803cbca608b9e58647b75a75ac173 100644 (file)
@@ -148,8 +148,8 @@ tar.<format>.command::
        to the command (e.g., `-9`).
 +
 The `tar.gz` and `tgz` formats are defined automatically and use the
-command `gzip -cn` by default. An internal gzip implementation can be
-used by specifying the value `git archive gzip`.
+magic command `git archive gzip` by default, which invokes an internal
+implementation of gzip.
 
 tar.<format>.remote::
        If true, enable the format for use by remote clients via
index efba78118b7f38d5d2b72e5e81bb7804916713e5..3d77e0f75095743d3da9874832e2f8bdccf5e896 100644 (file)
@@ -526,9 +526,9 @@ void init_tar_archiver(void)
        int i;
        register_archiver(&tar_archiver);
 
-       tar_filter_config("tar.tgz.command", "gzip -cn", NULL);
+       tar_filter_config("tar.tgz.command", internal_gzip_command, NULL);
        tar_filter_config("tar.tgz.remote", "true", NULL);
-       tar_filter_config("tar.tar.gz.command", "gzip -cn", NULL);
+       tar_filter_config("tar.tar.gz.command", internal_gzip_command, NULL);
        tar_filter_config("tar.tar.gz.remote", "true", NULL);
        git_config(git_tar_config, NULL);
        for (i = 0; i < nr_tar_filters; i++) {
index 9ac0ec67fe1af5822fe59a9741efc411f99b63eb..1a68e89a55c819670dbfb1a29c9542d0172259d4 100755 (executable)
@@ -339,21 +339,21 @@ test_expect_success 'only enabled filters are available remotely' '
        test_cmp_bin remote.bar config.bar
 '
 
-test_expect_success GZIP 'git archive --format=tgz' '
+test_expect_success 'git archive --format=tgz' '
        git archive --format=tgz HEAD >j.tgz
 '
 
-test_expect_success GZIP 'git archive --format=tar.gz' '
+test_expect_success 'git archive --format=tar.gz' '
        git archive --format=tar.gz HEAD >j1.tar.gz &&
        test_cmp_bin j.tgz j1.tar.gz
 '
 
-test_expect_success GZIP 'infer tgz from .tgz filename' '
+test_expect_success 'infer tgz from .tgz filename' '
        git archive --output=j2.tgz HEAD &&
        test_cmp_bin j.tgz j2.tgz
 '
 
-test_expect_success GZIP 'infer tgz from .tar.gz filename' '
+test_expect_success 'infer tgz from .tar.gz filename' '
        git archive --output=j3.tar.gz HEAD &&
        test_cmp_bin j.tgz j3.tar.gz
 '
@@ -363,31 +363,31 @@ test_expect_success GZIP 'extract tgz file' '
        test_cmp_bin b.tar j.tar
 '
 
-test_expect_success GZIP 'remote tar.gz is allowed by default' '
+test_expect_success 'remote tar.gz is allowed by default' '
        git archive --remote=. --format=tar.gz HEAD >remote.tar.gz &&
        test_cmp_bin j.tgz remote.tar.gz
 '
 
-test_expect_success GZIP 'remote tar.gz can be disabled' '
+test_expect_success 'remote tar.gz can be disabled' '
        git config tar.tar.gz.remote false &&
        test_must_fail git archive --remote=. --format=tar.gz HEAD \
                >remote.tar.gz
 '
 
-test_expect_success 'git archive --format=tgz (internal gzip)' '
-       test_config tar.tgz.command "git archive gzip" &&
-       git archive --format=tgz HEAD >internal_gzip.tgz
+test_expect_success GZIP 'git archive --format=tgz (external gzip)' '
+       test_config tar.tgz.command "gzip -cn" &&
+       git archive --format=tgz HEAD >external_gzip.tgz
 '
 
-test_expect_success 'git archive --format=tar.gz (internal gzip)' '
-       test_config tar.tar.gz.command "git archive gzip" &&
-       git archive --format=tar.gz HEAD >internal_gzip.tar.gz &&
-       test_cmp_bin internal_gzip.tgz internal_gzip.tar.gz
+test_expect_success GZIP 'git archive --format=tar.gz (external gzip)' '
+       test_config tar.tar.gz.command "gzip -cn" &&
+       git archive --format=tar.gz HEAD >external_gzip.tar.gz &&
+       test_cmp_bin external_gzip.tgz external_gzip.tar.gz
 '
 
-test_expect_success GZIP 'extract tgz file (internal gzip)' '
-       gzip -d -c <internal_gzip.tgz >internal_gzip.tar &&
-       test_cmp_bin b.tar internal_gzip.tar
+test_expect_success GZIP 'extract tgz file (external gzip)' '
+       gzip -d -c <external_gzip.tgz >external_gzip.tar &&
+       test_cmp_bin b.tar external_gzip.tar
 '
 
 test_expect_success 'archive and :(glob)' '