git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Cristian Le" <cristian.le@mpsd.mpg.de>,
	git@vger.kernel.org,
	"Matthias Görgens" <matthias.goergens@gmail.com>
Subject: Re: Bug in git archive + .gitattributes + relative path
Date: Sat, 18 Mar 2023 22:30:24 +0100	[thread overview]
Message-ID: <9e215e5c-0b67-0362-fd53-8c22b8d348ff@web.de> (raw)
In-Reply-To: <xmqqjzzly84q.fsf@gitster.g>

Am 12.03.23 um 22:25 schrieb Junio C Hamano:
> René Scharfe <l.s.r@web.de> writes:
>
>>>  * fail loudly when "git -C sub archive <pathspec>" makes us use
>>>    "../" prefix because <pathspec> goes above the $PWD for backward
>>>    compatibility and sanity.
>>
>> Without the patch this fails, but are there really people that depend on
>> it failing?  We could certainly forbid it, but do we need to?
>
> I dunno.  It was an obvious way to avoid having to think about
> interaction with --strip-components and "../", but there certainly
> may be other solutions for it people can think of.
>
> Also on the receiving end, don't people get upset to see that their
> "tar xf" escapes the directory they just created only to extract the
> tarball?

bsdtar creates entries starting with "../" without complaint, but
refuses to extract them as-is -- you need to e.g. use --strip-components
to get rid of those dots.  Awkward.

Not allowing those entries to be created is more consistent, especially
since we're already restrictive like that.  OK.

>>>  * with --some-option, make "git -C sub archive --some-option :/"
>>>    act exactly like "git archive :/".
>>
>> Perhaps I'm reading this too literally, but it would be easier to remove
>> "-C sub" from that command. Or to add "-C $(git rev-parse --show-cdup)".
>> We could add a shortcut for that (see patch below).
>
> More like
>
> 	$ cd some/deep/place
> 	... work work work
> 	$ git archive --full-tree :/other :/hier :/archy
>
> is what I had in mind.  Without --full-tree, due to the first bullet
> point above, paths in our archive are relative to some/deep/place.

I don't see the difference.  Here ":/other" is the youngest commit with
"other" in its message, ":/hier" and ":/archy" are pathspecs selecting
subdirectories.  If we stay in a different subdirectory then this is
simply currently forbidden and we'd keep it like that:

   $ cd xdiff
   $ git archive :/needle :/t/t0019 :/t/t4020 | tar tf -
   fatal: pathspec ':/t/t0019' did not match any files

We'd just improve the message a bit.  Going up still helps:

   $ git -C "$(git rev-parse --show-cdup)" archive :/needle :/t/t0019 :/t/t4020 | tar tf -
   t/
   t/t0019/
   t/t0019/parse_json.perl
   t/t4020/
   t/t4020/diff.NUL

   # We could shorten that.
   $ ../git --cdup archive :/needle :/t/t0019 :/t/t4020 | tar tf -
   t/
   t/t0019/
   t/t0019/parse_json.perl
   t/t4020/
   t/t4020/diff.NUL

Or am I missing something here?

René

  reply	other threads:[~2023-03-18 21:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 10:25 Bug in git archive + .gitattributes + relative path Cristian Le
2023-03-03 15:19 ` René Scharfe
2023-03-03 15:38   ` Cristian Le
2023-03-04 13:58     ` René Scharfe
2023-03-04 15:11       ` Cristian Le
2023-03-05  9:32         ` René Scharfe
2023-03-06 16:56       ` Junio C Hamano
2023-03-06 17:51         ` René Scharfe
2023-03-06 17:27       ` Junio C Hamano
2023-03-06 18:28         ` René Scharfe
2023-03-06 18:59           ` Junio C Hamano
2023-03-06 21:32             ` René Scharfe
2023-03-06 22:34               ` Junio C Hamano
2023-03-11 20:47                 ` René Scharfe
2023-03-12 21:25                   ` Junio C Hamano
2023-03-18 21:30                     ` René Scharfe [this message]
2023-03-20 16:16                       ` Junio C Hamano
2023-03-20 20:02                       ` [PATCH] archive: improve support for running in a subdirectory René Scharfe
2023-03-21 22:59                         ` Junio C Hamano
2023-03-24 22:26                           ` René Scharfe
2023-03-24 22:27                         ` [PATCH v2] archive: improve support for running in subdirectory René Scharfe
2023-03-27 16:09                           ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=9e215e5c-0b67-0362-fd53-8c22b8d348ff@web.de \
    --to=l.s.r@web.de \
    --cc=cristian.le@mpsd.mpg.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=matthias.goergens@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).