From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 4FEF71F4D7 for ; Thu, 26 May 2022 18:58:22 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=web.de header.i=@web.de header.b="MXQjkQWc"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348649AbiEZS6U (ORCPT ); Thu, 26 May 2022 14:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbiEZS6S (ORCPT ); Thu, 26 May 2022 14:58:18 -0400 Received: from mout.web.de (mout.web.de [217.72.192.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4D6DCC169 for ; Thu, 26 May 2022 11:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1653591472; bh=YC//nQJVtJMG/TFQtM0HOEqpNHKZ58KRjp8JeoHEwsw=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=MXQjkQWc0asKJ8H5pL+2+YoZMmqCn35wwpsTYPSlf18wE9+cMhkpJtaM98WmdQcf1 ORmnwll+9gy4DDlBkF7us1pkQRMSOAuM6aUH5JgbmTSGHM7xmrlHTeLQIXTKQ1hIrS rtD07kFoCEnxpd3gxvFCu1xW15LZwu/NPPM9PjA0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [192.168.178.29] ([79.203.31.99]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M6HK6-1nwVbM1w9A-006yu6; Thu, 26 May 2022 20:57:52 +0200 Message-ID: Date: Thu, 26 May 2022 20:57:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v6 1/7] archive: optionally add "virtual" files Content-Language: en-US To: Junio C Hamano Cc: Johannes Schindelin via GitGitGadget , git@vger.kernel.org, Taylor Blau , Derrick Stolee , Elijah Newren , rsbecker@nexbridge.com, =?UTF-8?B?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Johannes Schindelin References: <0005cfae31d52a157d4df5ba3db9f9f5b2167ddc.1653145696.git.gitgitgadget@gmail.com> <7815a07a-da2f-d348-4179-6dc5b1d5fee6@web.de> From: =?UTF-8?Q?Ren=c3=a9_Scharfe?= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:ijM2SRby7GGnw4YkkdwewEfgIzHOwrCY/bgsaD19LR99sVaugUd Fn3rEZTiXmrhy5T5JC8tigZOx2INBOtNbelVDpFAUEIZI+l7UBDsI9w+EmyrXEM4yM3K99r xQ0Lks6QVBftj/7KLI/VZThs+VM/olghTNVk+Uhe9fPbE7nurMgxbnl9KEIyQGPEus2skkK nSQxUxJPq0gQd/DJmebgA== X-UI-Out-Filterresults: notjunk:1;V03:K0:6mpa4igplXs=:PRk4y2y2W5Ur3GK1DpHyKw lbz8GNhqWaucRW5v7ckdU2Lu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E3TMal ZMM9Dd1BZ/tNt+/g/Dkr+sVemTLc6bk9NsN Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Am 26.05.22 um 19:10 schrieb Junio C Hamano: > Ren=C3=A9 Scharfe writes: > >> If the prefix is applied then a prefix-less extra file can by had by >> using --prefix=3D or --no-prefix for it and --prefix=3D... for the tree= , >> e.g.: >> >> $ git archive --add-file=3Dextra --prefix=3Ddir/ v2.36.0 >> >> puts "extra" at the root and the rest under "dir". The order of >> arguments matters here, and the default prefix is the empty string. > > This was the part of the design for the original "--add-file" that I > was moderately unhappy with. If "--add-file" were the only feature > that used "--prefix", I wouldn't have been unhappy, but this rule: > > The value of "--prefix" most recently seen at the point of > "--add-file" is prepended. (By the way, it is not clearly > documented what happens when you give multiple prefix and > when you give prefix before or after add-file) Regarding documentation: I wonder what's missing; a guess is below. > > makes the original use of "--prefix": > > The value given to "--prefix" is prepended to each filename > in the archive. (IOW "git archive --prefix=3Dgit-2.36.0/ > v2.36.0" is a way to prefix each and every path in the > tree-ish with the given prefix) > > confusing. Does > > git archive --prefix=3Dbonus-files/ --add-file=3Dextra v2.36.0 > > place the main part of the archive also in bonus-files/ or at the > top level? One reasonable interpretation is "yes", if we imagine > that each invocation of --add-file will consume and reset the prefix. > Another reasonable interpretation is "no", if we imagine that the > prefix last specified will stay around and equally affect both extra > ones and main part of the archive. > > Unfortunately what the implmentation does is the latter, and those > who want to put the main part of the archive at the top-level must > add "--prefix=3D''" at the end (before the tree-ish). A one-shot --prefix would be surprising -- usually options keep their value until they are specified again with a different value or negated (--no-...). That surprise could be documented away by using a different name like --next-prefix or --single-use-prefix. But a sub-option to a single option like that would probably be better baked into that option, e.g. allow --add-file=3D:. > > Because of this potential for confusion ... > >> So extra files can be put anywhere even if --prefix is honored. >> >> Keeping the whole path from --add-virtual-file makes sense to me; I >> slightly prefer applying --prefix on top of that for consistency. > > ... I was hoping that we can releave users from having to worry > about the interaction between "prefix" and contents coming from > outside the tree-ish by ignoring the "prefix". > > But either is fine by me. The unusual thing about the current --prefix implementation is that its current value is captured along the way instead of just using its right-most value. Not sure ignoring it for one of the three archive content sources helps. (Really, it's hard for me to put me in the shoes of someone who doesn't know how these options are supposed to be used.) =2D-- >8 --- Subject: [PATCH] archive: improve documentation of --prefix Document the interaction between --add-file and --prefix by giving an example. Signed-off-by: Ren=C3=A9 Scharfe =2D-- Documentation/git-archive.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt index bc4e76a783..10a48ab5f8 100644 =2D-- a/Documentation/git-archive.txt +++ b/Documentation/git-archive.txt @@ -49,7 +49,9 @@ OPTIONS Report progress to stderr. --prefix=3D/:: - Prepend / to each filename in the archive. + Prepend / to each filename in the archive. Can be + specified multiple times; the last one seen when reading from + left to right is applied. -o :: --output=3D:: @@ -58,8 +60,8 @@ OPTIONS --add-file=3D:: Add a non-tracked file to the archive. Can be repeated to add multiple files. The path of the file in the archive is built - by concatenating the value for `--prefix` (if any) and the - basename of . + by concatenating the current value for `--prefix` (if any) and + the basename of . --worktree-attributes:: Look for attributes in .gitattributes files in the working tree @@ -194,6 +196,12 @@ EXAMPLES commit on the current branch. Note that the output format is inferred by the extension of the output file. +`git archive -o latest.tar --prefix=3Dbuild/ --add-file=3Dconfigure --pre= fix=3D HEAD`:: + + Creates a tar archive that contains the contents of the latest + commit on the current branch with no prefix and the untracked + file 'configure' with the prefix 'build/'. + `git config tar.tar.xz.command "xz -c"`:: Configure a "tar.xz" format for making LZMA-compressed tarfiles. =2D- 2.35.3