Subject: Re: Bug in git archive + .gitattributes + relative path

From: Junio C Hamano <[email-masked]>
Date: Mon, 06 Mar 2023 09:27:41 -0800

René Scharfe <[email-masked]> writes:

> Subject: [PATCH] archive: add --strip-components
>
> Allow removing leading elements from paths of archive entries.  That's
> useful when archiving sub-directories and not wanting to keep the
> common path prefix, e.g.:
>
>    $ git archive --strip-components=1 HEAD sha1dc | tar tf -
>    .gitattributes
>    LICENSE.txt
>    sha1.c
>    sha1.h
>    ubc_check.c
>    ubc_check.h
>
> The same can be achieved by specifying a tree instead of a commit and
> a pathspec:
>
>    $ git archive HEAD:sha1dc | tar tf -
>    .gitattributes
>    LICENSE.txt
>    sha1.c
>    sha1.h
>    ubc_check.c
>    ubc_check.h

Another way I am not sure is working as designed is

    $ cd sha1dc && git archive HEAD . | tar tf -
    .gitattributes
    LICENSE.txt
    sha1.c
    sha1.h
    ubc_check.c
    ubc_check.h

I didn't check if the attribute look-up is done on the correct path
or export-subst kicks in in such a use, though.