From patchwork Sun Jun 12 06:03:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 12878649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CD59C43334 for ; Sun, 12 Jun 2022 06:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbiFLGEL (ORCPT ); Sun, 12 Jun 2022 02:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbiFLGEL (ORCPT ); Sun, 12 Jun 2022 02:04:11 -0400 Received: from mout.web.de (mout.web.de [212.227.15.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4EA112AD6 for ; Sat, 11 Jun 2022 23:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1655013839; bh=l25bGK4F8qm1yqKuZ/f4WA2c4yj52roMCXYwFXn623Q=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=PkQupart+mL7F+X7pTzJ/jQS0Gry/Tngi16bKyeXonIJZWTs7/IDKkR9ahmw3OlU4 3VUnbfIFe6fmGuysrHF0Ej6S7tFlfXu8O1xSX0Hy/UKK8G1aNAqJSd+E7W7tx0eyEX AnPKRjssAmA87zKHvFJmoqooCqLlKYQe06LPXzA8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.29] ([79.203.31.99]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MCXVX-1nrmOL429D-009cD6; Sun, 12 Jun 2022 08:03:59 +0200 Message-ID: <35db4457-1f86-ce05-baeb-51be57393bb4@web.de> Date: Sun, 12 Jun 2022 08:03:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH v3 1/5] archive: rename archiver data field to filter_command Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Rohit Ashiwal , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= , Jeff King , "brian m . carlson" References: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> In-Reply-To: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> X-Provags-ID: V03:K1:cbNCXD7s8jsih4SsPQj1mkN8gdecZeKryXYe5JbH+3yGr6LTVqm m45RZoHgFBRHNI9OHNxqR0BZelD+GLHSVO3f9a2q0AxU1vjk6dLWQVLCyRnCzWSqpa0Pia7 C5WBmAPBbrYCd5vJey18ohSdqZbb6v8SYJvDLo3ko6O7irNPFYxWMuxd+sHZdM9ntjSA2h4 +wqE6Dskmrf1AbHJPd06g== X-UI-Out-Filterresults: notjunk:1;V03:K0:5l/qbfeSPws=:9/SMlwn0mZz8EC5qIl8ZLr A38cbh9n53fKui/J9dx0pYRJeipk8KXWBVJk/6Sa3Yvd1/icMr34v638cnlmpZYSCyeDMzuFm 4MEv4tn4TrUrFw7+Eg82tK1X9xIv5O3520m/9ByScjnKGMNw5RhBIUmG19e8mMJtEdr2n2MA0 66JAIqs4Tcc44oa9GYQmR/SbXYXpJZ1qEmGHwq4cp2BQyYW6bNioZwcJcsnoY93EnPrtoTz85 7ddvHcLcG9vkqX97X4lyvxeQbAtdvxx/5JWCgTeOmkSz4SdQk+trsBzjDov9zSqWYUxoPLS4O TM1fRPZIgY0yezVbvwAHxdSYC8xjWSKFbiAIWALrvMfhmVQe8aXDxrJ3eyzICVCAcpZfW2aKi cv2Z+l67W6kwG3VfhigllRZurmz7AhJwF3NxdRkal+aJ/xsiJhF27RyediWRKaJLnTC/7lTsW s/vteHjkuTv4bSLEx8SNh+dtRZvuX0/OfJSDm6UsttDflxup0naru/p6+BDfa6wD5QLsu9DLS Vz6szYe25XxSogBj/pU2suBD9yGoHX0PcCtRWwfK6b5OCjtcHu1YUQ83t+w6bG+Odwnpa2frs IS/AdlpcBOJjypUJd4B8ZxD4u7Au+Ch1AHMq/sLTkJsRG6cFrwPCWTk/niodU+KhWZk9Vgbhh zVq7SCjMPti0Oa4Jmuy2OGrr+cNVUr2pX1+OeRHZ92Z2k8am+7NtSg48O8SRRgbFwz5j9wX/4 Vlbb+P7YgQmfd7pgzgScnyaJBrjbMMc4xvTPPyPwrtwLuF8tYDpizOtCYLiq1RwKG2uh05JNt wotdaEt3Ly4FO0IBGRK4zzES84PNILpTLRiLHhuYtIqZ0pU7fcpuOrPqORNVnwvMWQo7UwAcO z/wn3iwqqYDLVqOFO3/ai4L0LjdyNQF0q+sU2EXNsR3VilYYt4xhEx/19RuFtskBfxb+ppw2/ c0h/WGwS/L3U/PpxYQfctZm8QbaoLLw428C2zrdjBYyimo48rMz3KIkYZrjeYdu8Hjlf+OYbs jFSuE/j8ydaX3rIHl+3hvgrfEznyfpNWSAomj4PuMzrocNPTH18xTZsthnzlYnNy7wb6CQkuH /N+JlLq9EcdFhSfEwNLMb7by5rKXUHwMdGJ Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The void pointer "data" in struct archiver is only used to store filter commands to pass tar archives to, like gzip. Rename it accordingly and also turn it into a char pointer to document the fact that it's a string reference. Signed-off-by: René Scharfe --- archive-tar.c | 10 +++++----- archive.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) -- 2.36.1 diff --git a/archive-tar.c b/archive-tar.c index 042feb66d2..2717e34a1d 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -383,8 +383,8 @@ static int tar_filter_config(const char *var, const char *value, void *data) if (!strcmp(type, "command")) { if (!value) return config_error_nonbool(var); - free(ar->data); - ar->data = xstrdup(value); + free(ar->filter_command); + ar->filter_command = xstrdup(value); return 0; } if (!strcmp(type, "remote")) { @@ -432,10 +432,10 @@ static int write_tar_filter_archive(const struct archiver *ar, struct child_process filter = CHILD_PROCESS_INIT; int r; - if (!ar->data) + if (!ar->filter_command) BUG("tar-filter archiver called with no filter defined"); - strbuf_addstr(&cmd, ar->data); + strbuf_addstr(&cmd, ar->filter_command); if (args->compression_level >= 0) strbuf_addf(&cmd, " -%d", args->compression_level); @@ -478,7 +478,7 @@ void init_tar_archiver(void) git_config(git_tar_config, NULL); for (i = 0; i < nr_tar_filters; i++) { /* omit any filters that never had a command configured */ - if (tar_filters[i]->data) + if (tar_filters[i]->filter_command) register_archiver(tar_filters[i]); } } diff --git a/archive.h b/archive.h index 49fab71aaf..08bed3ed3a 100644 --- a/archive.h +++ b/archive.h @@ -43,7 +43,7 @@ struct archiver { const char *name; int (*write_archive)(const struct archiver *, struct archiver_args *); unsigned flags; - void *data; + char *filter_command; }; void register_archiver(struct archiver *); From patchwork Sun Jun 12 06:05:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 12878650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88270C43334 for ; Sun, 12 Jun 2022 06:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234047AbiFLGGF (ORCPT ); Sun, 12 Jun 2022 02:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbiFLGGE (ORCPT ); Sun, 12 Jun 2022 02:06:04 -0400 Received: from mout.web.de (mout.web.de [212.227.15.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB23119C10 for ; Sat, 11 Jun 2022 23:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1655013937; bh=qsdawq715O/V/nmmBycYUKaJbChEBTxQP9xdGa7cxHw=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=i/FQcIE/UCDioV2c8ecACF3m7Ts1NByGV8Q7pxDjy+jAYJdwfFCqjUAz6cMLW+Ewg NRzvl+MOM8G+eRQVgJWeBTWkX2Qm0edz4BIjchplaaf1K/Y4/Lpr5qMKq84XDNYbxl bZe245xRZq0igjJo1zBGZxVhbyZCIiaeMGlzf1KI= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.29] ([79.203.31.99]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N5UgI-1nh0g64842-016l8K; Sun, 12 Jun 2022 08:05:37 +0200 Message-ID: <0c7a4261-47e6-941f-bd0c-4ecc646bb124@web.de> Date: Sun, 12 Jun 2022 08:05:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH v3 2/5] archive-tar: factor out write_block() Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Rohit Ashiwal , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= , Jeff King , "brian m . carlson" References: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> In-Reply-To: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> X-Provags-ID: V03:K1:HFRQ8GIFNgO/2VjM39nuU+bGm+qBME5kYKjpuvs+XWifhBLfbfP ri6a3NDrCjL8DpHtpNpKaXiioQSY31e91zLSF5CWn9c1qvEXRrPrRV/CqiADqsLpbSIeH6H Xw6mvHid0r355gxwWlGJsJBSnEN2l3VF9yH7i4+kcuTTZH5p73Oj+CMla2jRNuclXI13SN0 LswfIOlOJkinDbBOGDbQw== X-UI-Out-Filterresults: notjunk:1;V03:K0:le9+ddnGe44=:EoUj6Q8g9Wvqf0CXNbDGsT i5Cf4YfRa5OJc00hp9D9fyQzVyxndoF3jYiiWXNkzQ3h839D79oRI/UCpI7GxsZ9yZ6gOkiX7 yQ3Un4hP995iDjK2donklpdhuo1z+BSp9N/nL9YFpbKuxnX8CO3/WN5rozQwhipByXnIf1cZP BkkdJNztuzIhA+cdGjul31DkTTQ1FaCmCubJU8whJO7MR7sF8DTNqthHkIUj9BprtwsjT9XCU 3quTISBzCviou0+dImW2sxdVouOIGU9XVHqgBkAk5ogErJrP9oWaSZm0gJNXu9+AuA9KUulPn g7ZqOm2oU36yRmkwh8k3gkiLHfq+/HfOqn2GeklqvnlXW09Ghwg3GLT2M3Usrb5iy5y2RqivE mI0SBlMmpT2hq8yiOlJXBaC1+7JN7ON3gCZJgkADauf0TysWOAJaK/RNpPbxHhvRWbC4AS9+O /P//9mxfIZpejaC0xxvItyPCpnyCPwAncS670YL8EmLMY4apUvYFPbCalLbp4NYpMVS9nwL0M QDjozseeVWWB6aL1OYk93VMCQ5RDbwlLzKYiIkbRaDQ1e9tNQula2TJGGWrkIvaI2aAvLvvMl cEVu7sSYP/ePt9tOzeLsL8GeHYXALbj1OLq9wKWg3E6C/VS0olvukeriurw1OppE5SQy7pVef swom1seuO4Xo7OKp/fb1+LFNN4gFIJ2jJMGQo67fEToPE9VZdaswuQBJ3D+ry1epGNQHwoANb dr+njL2dMpwBL/eGpFOSnnSmeG8UOLWUzztQ0tk6UWcjQaOk/6MBcEJMv1YnIQlVpZitUqoSo /rTwJE1kzZjfQJMWRNtV3PHkP5s0YtEfP5O3zA11SP6Xfm20cHHNoVwhhvDqz1pnohpt/rDjl cmc02ydS32Yss6c0Mt+EI+Lw05u2busV2oC03YU2EqgzxGgicnRR9mD6rNB8EqeJMTphbdLem 2UFlWgzRFAu9Ni2ItkP+ux4AWJ0BZhJO0e8Sh+jq5CGfIkbUoT8YtFfi1pSVbvsE2vt+7QjCV QUW1zZxKD8/A0TymvztgOYbKuUL48IqxXQQLoKlqAiUV5gMKBSX4fqMK3X7eEVviPLeMxx+0T 64bQKbNabCjwAmV6Vw/887o1Yg8aIhBA+nG Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org All tar archive writes have the same size and are done to the same file descriptor. Move them to a common function, write_block(), to reduce code duplication and make it easy to change the destination. Original-patch-by: Rohit Ashiwal Signed-off-by: René Scharfe --- archive-tar.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.36.1 diff --git a/archive-tar.c b/archive-tar.c index 2717e34a1d..4e6a3deb80 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -38,11 +38,16 @@ static int write_tar_filter_archive(const struct archiver *ar, #define USTAR_MAX_MTIME 077777777777ULL #endif +static void write_block(const void *buf) +{ + write_or_die(1, buf, BLOCKSIZE); +} + /* writes out the whole block, but only if it is full */ static void write_if_needed(void) { if (offset == BLOCKSIZE) { - write_or_die(1, block, BLOCKSIZE); + write_block(block); offset = 0; } } @@ -66,7 +71,7 @@ static void do_write_blocked(const void *data, unsigned long size) write_if_needed(); } while (size >= BLOCKSIZE) { - write_or_die(1, buf, BLOCKSIZE); + write_block(buf); size -= BLOCKSIZE; buf += BLOCKSIZE; } @@ -101,10 +106,10 @@ static void write_trailer(void) { int tail = BLOCKSIZE - offset; memset(block + offset, 0, tail); - write_or_die(1, block, BLOCKSIZE); + write_block(block); if (tail < 2 * RECORDSIZE) { memset(block, 0, offset); - write_or_die(1, block, BLOCKSIZE); + write_block(block); } } From patchwork Sun Jun 12 06:08:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 12878651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CC45C433EF for ; Sun, 12 Jun 2022 06:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234047AbiFLGI6 (ORCPT ); Sun, 12 Jun 2022 02:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiFLGI4 (ORCPT ); Sun, 12 Jun 2022 02:08:56 -0400 Received: from mout.web.de (mout.web.de [212.227.15.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D4E21B7B7 for ; Sat, 11 Jun 2022 23:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1655014116; bh=xmhi2u/Xgh/67bSnp3cHzvvsNcqXHIzfxmiMRL/ycVw=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=Iza3q+qDSIP3bBvn1L6fuylGQaDTk8d+KUQvh7nBmT6JcwFQ11uheT5wPmhQDDREv 9sgHNSIiRLzA8Ri/XTtj7zN1dGI4P197ctDOAJd2ew+3tCJQ1260XjIg281iX5+Omj h6WSpGiLEYWST1YXKUxacGKCN/aj9tcQjdhLqBKU= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.29] ([79.203.31.99]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MF2gW-1ny86t49we-00Fbb7; Sun, 12 Jun 2022 08:08:36 +0200 Message-ID: <75e76d0f-2ab0-ebf7-4a4e-7a6e0fca0b1a@web.de> Date: Sun, 12 Jun 2022 08:08:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH v3 3/5] archive-tar: add internal gzip implementation Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Rohit Ashiwal , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= , Jeff King , "brian m . carlson" References: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> In-Reply-To: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> X-Provags-ID: V03:K1:I/CazHmT9gy6drh62Qk9Znyiap60EALm2e6/UAaWxMpYiE2GE1w iEiTAEZFSdhp0TpMiQjLoliC5oehAFQhJBmKMw27+4OZZcDZpjmuRHTZXUUHzO2LlPKUSWg +tojEb/+SFGcVkkQUTR4zzhwhPdwtUowOIbElDG9eEBiryHWJkGP3+Vpvrnl98d8s4pjShC ynDK0P4qaUzAwkwo6eTyg== X-UI-Out-Filterresults: notjunk:1;V03:K0:kShSi/1QB8o=:BqfPq940qQUZZJJm1mmkUu hEpRmVgQCNA23ndZzgYdGImGqJyp3hqz/6Gg+86eqBVwPbVhtjCJCdpYBrH0Pj9mPPDHL66mm y5128xJF89qBHd8PWdjdM5bBK5yp+JqBLvvbPfjWhYd4F77PkPE8vDiCsz+QC36s+B6hoedBl PHWajq6v4jVE/cn//Ehg2/50q/uPJ5sQ6pYCiS7uT8QPBt4wOf0BsmriknskkSbT8jn3EBPwX g8YWGQu0j0ywfSfM+fQX5Hwmj+WIqEdbmybE1pnP/PCqsLqNlxQt8y2lxEKBP9ZKdo5U7lUHA 7unM+tlFozqDtcULqZYBIhU2/UeSJ88+stWGJFdIXIEZ/vr0EDeYWbciTdjFKYWVwlf2FLbAK +g3SrZdO32OC8trW6kTQbJnnfqYMJyECLknwyzE0VLuNAgBy1c3sUHBWs+DG7ZY+wvcVDiLWW rpa2Xa3roOudFm/j2JPRh6qtlf8qBUVE8zntaLU6NVXX9Ewbp9BUjtIb3xnetukF9Fx1gEjM1 yen0sWvvlZc27nEk3Fm82kOAyPlrGv0iUaiTeBqbDY0XKsoDJXHajOjLOC7I1UUTrewcXD5ag JFFORUVNujF5p7OxNaCQkKHAWEw+pjGtDPDtyillKRZvxfLFFAmHcKWow9cZUhxANzBrpbphj pmMkBF/QmpY2MnlRDsRBu1D0jtd93QF17j9wQYd774RYQlL9aHy8CM4gLgZptZWQQAxtAyKzF u1NlEUdbuZVwTsSXSuObZSCgMoe2/WFAEWM4bS6P/Z6/i9HSMpbU2YAej1tmWtZnrqAekx0nY 5Px2etYI5QjGP9VALOI24yfR1ua/UVFZsF6eGKZsLR/dh9wTUEbG3lHssTUWdBc9qlSXO+g/E Fn3U6zPXPuLksmcN9XLc6YDAjGMDkkxCNU1WIGbqX8yR39K8p4F8oGJr9nus3V7kkOKPsWgVJ vHMXCdkDxfNLJ57Z2YF5Kft9h9/6CwCwg/dLhvjHJ9OYtiVlhHsS18045IKvSrYHlVlsRW/z6 nkpLwbXuEnRv8He/3ajPIBApsE/qTA4Si7LkfxvOtdfj0vm9pTtzOpZlb5LtbGrP2CYbTdHgU yB48dFSCfhaPzLYKgRM8FAj9v8pJPNn0hww Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Git uses zlib for its own object store, but calls gzip when creating tgz archives. Add an option to perform the gzip compression for the latter using zlib, without depending on the external gzip binary. Plug it in by making write_block a function pointer and switching to a compressing variant if the filter command has the magic value "git archive gzip". Does that indirection slow down tar creation? Not really, at least not in this test: $ hyperfine -w3 -L rev HEAD,origin/main -p 'git checkout {rev} && make' \ './git -C ../linux archive --format=tar HEAD # {rev}' Benchmark #1: ./git -C ../linux archive --format=tar HEAD # HEAD Time (mean ± σ): 4.044 s ± 0.007 s [User: 3.901 s, System: 0.137 s] Range (min … max): 4.038 s … 4.059 s 10 runs Benchmark #2: ./git -C ../linux archive --format=tar HEAD # origin/main Time (mean ± σ): 4.047 s ± 0.009 s [User: 3.903 s, System: 0.138 s] Range (min … max): 4.038 s … 4.066 s 10 runs How does tgz creation perform? $ hyperfine -w3 -L command 'gzip -cn','git archive gzip' \ './git -c tar.tgz.command="{command}" -C ../linux archive --format=tgz HEAD' Benchmark #1: ./git -c tar.tgz.command="gzip -cn" -C ../linux archive --format=tgz HEAD Time (mean ± σ): 20.404 s ± 0.006 s [User: 23.943 s, System: 0.401 s] Range (min … max): 20.395 s … 20.414 s 10 runs Benchmark #2: ./git -c tar.tgz.command="git archive gzip" -C ../linux archive --format=tgz HEAD Time (mean ± σ): 23.807 s ± 0.023 s [User: 23.655 s, System: 0.145 s] Range (min … max): 23.782 s … 23.857 s 10 runs Summary './git -c tar.tgz.command="gzip -cn" -C ../linux archive --format=tgz HEAD' ran 1.17 ± 0.00 times faster than './git -c tar.tgz.command="git archive gzip" -C ../linux archive --format=tgz HEAD' So the internal implementation takes 17% longer on the Linux repo, but uses 2% less CPU time. That's because the external gzip can run in parallel on its own processor, while the internal one works sequentially and avoids the inter-process communication overhead. What are the benefits? Only an internal sequential implementation can offer this eco mode, and it allows avoiding the gzip(1) requirement. This implementation uses the helper functions from our zlib.c instead of the convenient gz* functions from zlib, because the latter doesn't give the control over the generated gzip header that the next patch requires. Original-patch-by: Rohit Ashiwal Signed-off-by: René Scharfe --- Documentation/git-archive.txt | 3 ++- archive-tar.c | 45 ++++++++++++++++++++++++++++++++++- t/t5000-tar-tree.sh | 16 +++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) -- 2.36.1 diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt index 56989a2f34..5b017c2bdc 100644 --- a/Documentation/git-archive.txt +++ b/Documentation/git-archive.txt @@ -148,7 +148,8 @@ tar..command:: format is given. + The "tar.gz" and "tgz" formats are defined automatically and default to -`gzip -cn`. You may override them with custom commands. +`gzip -cn`. You may override them with custom commands. An internal gzip +implementation can be used by specifying the value `git archive gzip`. tar..remote:: If true, enable `` for use by remote clients via diff --git a/archive-tar.c b/archive-tar.c index 4e6a3deb80..53d0ef685c 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -38,11 +38,13 @@ static int write_tar_filter_archive(const struct archiver *ar, #define USTAR_MAX_MTIME 077777777777ULL #endif -static void write_block(const void *buf) +static void tar_write_block(const void *buf) { write_or_die(1, buf, BLOCKSIZE); } +static void (*write_block)(const void *) = tar_write_block; + /* writes out the whole block, but only if it is full */ static void write_if_needed(void) { @@ -430,6 +432,34 @@ static int write_tar_archive(const struct archiver *ar, return err; } +static git_zstream gzstream; +static unsigned char outbuf[16384]; + +static void tgz_deflate(int flush) +{ + while (gzstream.avail_in || flush == Z_FINISH) { + int status = git_deflate(&gzstream, flush); + if (!gzstream.avail_out || status == Z_STREAM_END) { + write_or_die(1, outbuf, gzstream.next_out - outbuf); + gzstream.next_out = outbuf; + gzstream.avail_out = sizeof(outbuf); + if (status == Z_STREAM_END) + break; + } + if (status != Z_OK && status != Z_BUF_ERROR) + die(_("deflate error (%d)"), status); + } +} + +static void tgz_write_block(const void *data) +{ + gzstream.next_in = (void *)data; + gzstream.avail_in = BLOCKSIZE; + tgz_deflate(Z_NO_FLUSH); +} + +static const char internal_gzip_command[] = "git archive gzip"; + static int write_tar_filter_archive(const struct archiver *ar, struct archiver_args *args) { @@ -440,6 +470,19 @@ static int write_tar_filter_archive(const struct archiver *ar, if (!ar->filter_command) BUG("tar-filter archiver called with no filter defined"); + if (!strcmp(ar->filter_command, internal_gzip_command)) { + write_block = tgz_write_block; + git_deflate_init_gzip(&gzstream, args->compression_level); + gzstream.next_out = outbuf; + gzstream.avail_out = sizeof(outbuf); + + r = write_tar_archive(ar, args); + + tgz_deflate(Z_FINISH); + git_deflate_end(&gzstream); + return r; + } + strbuf_addstr(&cmd, ar->filter_command); if (args->compression_level >= 0) strbuf_addf(&cmd, " -%d", args->compression_level); diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index 7f8d2ab0a7..9ac0ec67fe 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -374,6 +374,22 @@ test_expect_success GZIP 'remote tar.gz can be disabled' ' >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 '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 'extract tgz file (internal gzip)' ' + gzip -d -c internal_gzip.tar && + test_cmp_bin b.tar internal_gzip.tar +' + test_expect_success 'archive and :(glob)' ' git archive -v HEAD -- ":(glob)**/sh" >/dev/null 2>actual && cat >expect < X-Patchwork-Id: 12878652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBEF7C433EF for ; Sun, 12 Jun 2022 06:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbiFLGSs (ORCPT ); Sun, 12 Jun 2022 02:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiFLGSq (ORCPT ); Sun, 12 Jun 2022 02:18:46 -0400 Received: from mout.web.de (mout.web.de [212.227.15.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3F539BA6 for ; Sat, 11 Jun 2022 23:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1655014701; bh=1UVCC78FdXD4x06vNF2gJTXUHfIxiKSYmgoRCp6h724=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=Cwz+OT5js8HpT/YkR5JHgbnKQDzAg+nHc8RbDEp43HVIGzCMpbJcGqyhjlHtCwqsP oZrmSvBILy/yzpdambaA18SPdJr3x1YnTvBZkKkUbMNUKd6AcsQlSxJSdj2KY5jKnI WoY5g0hnqWwh0ozWaajfEowH+mRyCwQDOInv/0cA= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.29] ([79.203.31.99]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M9ZZo-1o3aJc3Ra8-005kiY; Sun, 12 Jun 2022 08:18:20 +0200 Message-ID: <0a6877c3-07f2-b0e2-f23c-9ea4c588e8a5@web.de> Date: Sun, 12 Jun 2022 08:18:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH v3 4/5] archive-tar: use OS_CODE 3 (Unix) for internal gzip Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Rohit Ashiwal , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= , Jeff King , "brian m . carlson" References: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> In-Reply-To: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> X-Provags-ID: V03:K1:ZMD5m2x3NvG36FYnYGrEoWqUFYtakQdpuu8kP51VxxIHzxam956 DQwisIObJyQcUjeC+VFWN1fwqObuUqCyu5TvdAKjq3LZNaqGMHXL9izBu+OdoAJaz3i2ZBB 8CaOizSt1JwkhglnCWdMeG1zJF5llSoSOETk2UnqpYN/n5Nb+Qf4rUlsnt8ph/72//PKl4E gOctF/R7mkTC4euKm34Wg== X-UI-Out-Filterresults: notjunk:1;V03:K0:gF9pEg64btI=:sCd1qBLCt/X/oKw05HKrpW Knt4kxmgGT+KalDljIbobWNDfh+bXqF+lnhe5WozmLVaV18FMwQ36Ab2P3AK+IMsmrMG2Le03 FoGr1MbnIrKSL95n9EVv2PxxIaLEm0UIeqstH2TImCFJBOdi78HQio8+UJIYjLD0r/WV/CGOu bZell81ypIH+GEBnGFYfdSgu1LSN6wfl+ANaHj/7SiEYHJ/duB/xkxn/WT453UgJaBjAB3yVp 61xWKcQ9GbyUbhlcT6yJRmIZqxYYKc4VRZ3/PX69SaCgHfFXirNAbTkyjpMDoWsbeDwRKggrs l24/D2nx+xvlyonPEFpTLxzTALVszPUe8NWPk/NPqaG9hLckvu7ebBMQrDdoPjh6pdeBzOgej BqCLdUtXwVKWU82xmlihn0lsimpvjiuyLj0eE9j9LFfjKOfTy6q/4V6GgyjapMXvH/FEMKCpz ZXChuuIntirgkOCieNSa4xduBtq9f7TRrzjxWsBWjJJPJsegWlaObgRuVx7PYd0QOf1QCkmSW 3KJuxvqN/qWdEJsqN4k+8IaFTP9MuiOPVHGiV113UkQwaj9wAmMA1ji1PzZhna9gVfmrk6jbk b1P8fvPVnf+MPb2qQTYrKEJhhFB1DwhKQJsiDKFwjQHFOsO9EKBdcyhRZ5VbgEi5UsxN+MS0Q H/Iu9WOM0k9pdZYG8iuIig7Pn/tgiJA/VQjjOUtaCqSxpf1k2Rv3hVZFw88UU0BH2IHVVM+cI B06/DFjzyy3ZRSuAhVm66lLnLVkP0YkyfKMYjaXeKd6I93xt22qKa0M/pthgnZHEZtozuHO/L TPkO5B++Z34YLsDxcqThiopNJ7O4mvcJTaXcZod6yiXBVcTCeeGL2O1d2Z5E2IP+IZ8enyzNx pLnPTaZqzT1z6bYC89Z7xb/S3gWaZvBAsJJ5IyV/Te5gBVqzm3lk3HXJa1YE6C1MuVBIpYixo XviY/6nQuWIj0lXuT8YCU0K3yJs5KscXA0PG9UUy9i5tppBAmvpMsr6YU4VndtYnLCpZw7Uea gF6GS9x3rg1/RYhlfqUemeBycOc1jKBkJPr2wLb5R4pdtgs8Xir/PbLcy1lBOhSRT8njASVY1 WNUF4va6zWpsm2RB0owIDf6TiI698dxnjrA Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org gzip(1) encodes the OS it runs on in the 10th byte of its output. It uses the following OS_CODE values according to its tailor.h [1]: 0 - MS-DOS 3 - UNIX 5 - Atari ST 6 - OS/2 10 - TOPS-20 11 - Windows NT The gzip.exe that comes with Git for Windows uses OS_CODE 3 for some reason, so this value is used on practically all supported platforms when generating tgz archives using gzip(1). Zlib uses a bigger set of values according to its zutil.h [2], aligned with section 4.4.2 of the ZIP specification, APPNOTE.txt [3]: 0 - MS-DOS 1 - Amiga 3 - UNIX 4 - VM/CMS 5 - Atari ST 6 - OS/2 7 - Macintosh 8 - Z-System 10 - Windows NT 11 - MVS (OS/390 - Z/OS) 13 - Acorn Risc 16 - BeOS 18 - OS/400 19 - OS X (Darwin) Thus the internal gzip implementation in archive-tar.c sets different OS_CODE header values on major platforms Windows and macOS. Git for Windows uses its own zlib-based variant since v2.20.1 by default and thus embeds OS_CODE 10 in tgz archives. The tar archive for a commit is generated consistently on all systems (by the same Git version). The OS_CODE in the gzip header does not influence extraction. Avoid leaking OS information and make tgz archives constistent and reproducable (with the same Git and libz versions) by using OS_CODE 3 everywhere. NB: The function deflateSetHeader() was introduced by zlib 1.2.2.1, released 2004-10-31. At least on macOS 12.4 this produces the same output as gzip(1) for the examples I tried: # before $ git -c tar.tgz.command='git archive gzip' archive --format=tgz v2.36.0 | shasum 3abbffb40b7c63cf9b7d91afc682f11682f80759 - # with this patch $ git -c tar.tgz.command='git archive gzip' archive --format=tgz v2.36.0 | shasum dc6dc6ba9636d522799085d0d77ab6a110bcc141 - $ git archive --format=tar v2.36.0 | gzip -cn | shasum dc6dc6ba9636d522799085d0d77ab6a110bcc141 - [1] https://git.savannah.gnu.org/cgit/gzip.git/tree/tailor.h [2] https://github.com/madler/zlib/blob/master/zutil.h [3] https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT Signed-off-by: René Scharfe --- Perhaps makes sense for remote-curl as well (out of scope of this series)? archive-tar.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.36.1 diff --git a/archive-tar.c b/archive-tar.c index 53d0ef685c..bf7e321e0e 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -460,6 +460,14 @@ static void tgz_write_block(const void *data) static const char internal_gzip_command[] = "git archive gzip"; +static void tgz_set_os(git_zstream *strm, int os) +{ +#if ZLIB_VERNUM >= 0x1221 + struct gz_header_s gzhead = { .os = os }; + deflateSetHeader(&strm->z, &gzhead); +#endif +} + static int write_tar_filter_archive(const struct archiver *ar, struct archiver_args *args) { @@ -473,6 +481,7 @@ static int write_tar_filter_archive(const struct archiver *ar, if (!strcmp(ar->filter_command, internal_gzip_command)) { write_block = tgz_write_block; git_deflate_init_gzip(&gzstream, args->compression_level); + tgz_set_os(&gzstream, 3); /* Unix, for reproducibility */ gzstream.next_out = outbuf; gzstream.avail_out = sizeof(outbuf); From patchwork Sun Jun 12 06:19:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ren=C3=A9_Scharfe?= X-Patchwork-Id: 12878653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A625DC43334 for ; Sun, 12 Jun 2022 06:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234523AbiFLGTY (ORCPT ); Sun, 12 Jun 2022 02:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiFLGTY (ORCPT ); Sun, 12 Jun 2022 02:19:24 -0400 Received: from mout.web.de (mout.web.de [212.227.15.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0334239BA8 for ; Sat, 11 Jun 2022 23:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1655014745; bh=VKU4TSmiHTGdb75DWjKGpgdbGJuoyYmFY+hvStDAVao=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=npnlhlWTkyX7/xfiBB8QEH8QvhrORkz/gOwvYGdHzeBTwu7HvAxb/SE0PevgtO06N zGVpV2kECuZ6Stgd3WWrgsGtHqgjZ+LiklvyJTbx49QDhD/NJfonjZyYSS+6G+nvzO la0iWRbwGgRr+2PnpoNQALYE0R48kAMVqvzTVL/Y= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.29] ([79.203.31.99]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1MnX5F-1nGnBU2e8b-00jSa7; Sun, 12 Jun 2022 08:19:05 +0200 Message-ID: Date: Sun, 12 Jun 2022 08:19:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH v3 5/5] archive-tar: use internal gzip by default Content-Language: en-US From: =?utf-8?q?Ren=C3=A9_Scharfe?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Rohit Ashiwal , =?utf-8?b?w4Z2YXIgQXJuZmrDtnI=?= =?utf-8?b?w7AgQmphcm1hc29u?= , Jeff King , "brian m . carlson" References: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> In-Reply-To: <217a2f4d-4fc2-aaed-f5c2-1b7e134b046d@web.de> X-Provags-ID: V03:K1:t/cny2zg2ihPzkPprkLWHcT1FM2KE89qX52UUgd5411Kyjj4bzZ MRNNPCfrC+GKTjn6ZClypEb+gYtsRndOVjZQ9vjzgMWJ+T81AM5cTrqsAdo7rTNjN2prwt7 345fxkV5lSWcMpEWL8T2tR/KraOOoeOWliSL4CD1CQeapXo0Rt6FwKGkWefa1hzntGRJ2Og UuXkdAkmT/Hyj/6xE8D5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:bZFEO5ja+rY=:A1RPxVq02/fNvoKsN5b436 d1rRu4a0XYnuaSTz1c15z4amyiAh7Mv7D5e/Yj23v13ivSc7VZBl5mpoWpkS4E9BeJ+QZ+SY0 M7/eFGfHYYNhmD0s2aotfeWhnJssbzXh55WxjQ9jq1VTsb8ZO0A6podsQ88DaSRSTQC/MdS9P v2ecayfGNgqZcNZhANNarbO6yPtHCP/YcsAvLK5vXVD/RXplH8akFpUeAF+mNhs2bJXlIFcyr ApSZ7zO+Wtnzwx8ZAR6SXZFrHfu4l9QAmCBUGrQQCIJ9F4e4IJXkrPrvdivIlb/xTOpEa7efz gn9E7C3xfuJTTm3n1L42mSr8ZHJuRsNYWzQQwBmG9FYf28a0kUcWaAe3FZY0Q4uQ2OJqHMTwK GpZFylaVTZjFadcqWcnx+6M1lvJltZ6erpQdH/iq/+w1OTA2k4lMIyvclFYbSstR/485SLr6e slDDYeqINJf3n316my8SUNhETLmR92Am8d9L4vh4vSrHyanNi/U1z+MbZSGc/+Ses6SbHgKxk rXPy0D8PvMW4tRAXVz3UDKtt/mx9RxNr/cvJjkYQi+Z5S9vEiiugVoSdYVJn/7zDg1j8Vdfed us+Xmj/7EIYObeTldwhPtNhL5Rh7RM4JJeFSgBicBIHC5DuDXzuwK0DZ4bMTAiaGqOxxK8Rrh tAs+dkRRAxrbC/rtmJzuLObpRwCtFcSTnPrfTQr1vDPnRV6Xa2OlpQD5YOuQkQBXKZG6alpXM mrKsK838JJMEoBYxvwGGtiaNNw6PovlRYPofdPsZNcIwup3q8R87b7sjthrumGFpbll/k6evi qR5it9l51/sCS/8FpS18BJ8b/7Gv0sbmdSBURLJqigdWym353UsJ8pxfBBc4slqC1yLlxHVw6 I2TxkoAR8vnaxavJk+m+cYdps+iU1G+SjxpEW09GTRnTXoQVknAgf7tCnOII1FStqvBL3yWNA y1rNSN+mKAUPsilhEpndiOYBNfVrAOlDaRv0wzG1iArbYuxYEOIdZMoQzvYN/DCPxR+SAo9zO oABZTOxe6UNWdHRz79C7QTGvx3rajVTxStDLet/40R/shi4ICrd5lcRfjJGU27wjHKED3xJof liiHl+yQynnR6z7PqJxdK+mh1ajfBpnzmIE Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Drop the dependency on gzip(1) and use our internal implementation to create tar.gz and tgz files. Signed-off-by: René Scharfe --- Documentation/git-archive.txt | 4 ++-- archive-tar.c | 4 ++-- t/t5000-tar-tree.sh | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) -- 2.36.1 diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt index 5b017c2bdc..9de12896fc 100644 --- a/Documentation/git-archive.txt +++ b/Documentation/git-archive.txt @@ -148,8 +148,8 @@ tar..command:: format is given. + The "tar.gz" and "tgz" formats are defined automatically and default to -`gzip -cn`. You may override them with custom commands. An internal gzip -implementation can be used by specifying the value `git archive gzip`. +the magic value `git archive gzip`, which invokes an internal +implementation of gzip. You may override them with custom commands. tar..remote:: If true, enable `` for use by remote clients via diff --git a/archive-tar.c b/archive-tar.c index bf7e321e0e..60669eb7b9 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -528,9 +528,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++) { diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index 9ac0ec67fe..1a68e89a55 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -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.tar && - test_cmp_bin b.tar internal_gzip.tar +test_expect_success GZIP 'extract tgz file (external gzip)' ' + gzip -d -c external_gzip.tar && + test_cmp_bin b.tar external_gzip.tar ' test_expect_success 'archive and :(glob)' '