git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2023, 18:59 UTC
Message-ID
<xmqqo7p59049.fsf@gitster.g>
In-Reply-To
<d16c6a22-05d8-182c-97b4-53263d22eaa6@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 27 quoted lines
>> 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.hq
>>
>> 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.
>
> export-subst is supported in that invocation because git archive has a
> commit to work with.
>
> I can kinda see others preferring the directory prefix "sha1dc/" added
> to those entries.  Perhaps it depends on what git archive is supposed to
> archive: A commit or the files of a commit?  I'm in the latter camp, and
> expect to see the same paths as given by git ls-files or git ls-tree.
>
> But that invocation in a sub-directory probably has the same problem
> with attributes as the one with a sub-tree above it, i.e. that
> attributes are always looked up relative to the repository root.  I
> wonder if 47cfc9bd7d (attr: add flag `--source` to work with tree-ish,
> 2023-01-14) provided the means to fix this when it added a tree_oid
> parameter to git_check_attr().

It somehow feels that the use of pathspec in "git archive" is somewhat iffy, e.g.

   $ cd sha1dc && git archive HEAD :/ | tar tf -
does not compare very well with
   $ cd sha1dc && git ls-tree -r HEAD :/

For that matter, replacing ":/" (full tree) with ".." (we know one level above is the root of the working tree) has the same "why don't they work the same way???" confusion.

Previous: René ScharfeNext: René Scharfe
Message 11 of 22 in “Bug in git archive + .gitattributes + relative path”
  1. Cristian LeMar 3, 2023
  2. René ScharfeMar 3, 2023
  3. Cristian LeMar 3, 2023
  4. René ScharfeMar 4, 2023
  5. Cristian LeMar 4, 2023
  6. René ScharfeMar 5, 2023
  7. Junio C HamanoMar 6, 2023
  8. René ScharfeMar 6, 2023
  9. Junio C HamanoMar 6, 2023
  10. René ScharfeMar 6, 2023
  11. Junio C HamanoMar 6, 2023
  12. René ScharfeMar 6, 2023
  13. Junio C HamanoMar 6, 2023
  14. René ScharfeMar 11, 2023
  15. Junio C HamanoMar 12, 2023
  16. René ScharfeMar 18, 2023
  17. Junio C HamanoMar 20, 2023
  18. archive: improve support for running in a subdirectoryRené Scharfe, Mar 20, 2023
  19. Junio C HamanoMar 21, 2023
  20. René ScharfeMar 24, 2023
  21. archive: improve support for running in subdirectoryRené Scharfe, Mar 24, 2023
  22. Junio C HamanoMar 27, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.