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

Re: [PATCH] git-archive: document CWD effect

From
Junio C Hamano <junkio@cox.net>
Date
Apr 8, 2007, 23:21 UTC
Message-ID
<7virc68nc1.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<4618DFEE.8080707@lsrfire.ath.cx>
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 15 quoted lines
> Nick Williams schrieb:
>> git-archive only archives the current working dir (and sub dirs) even
>> when no paths are specified. For example, if I do
>> 
>> git archive --format=tar --prefix=git-1.5.0.2/ HEAD > ~/test/test.tar
>> 
>> from with in the Documentation dir, then I only get part of the tree.
>> 
>> Is this the intended behavior?
>> 
>> The reason I ask is that from my (mis)reading of the man page I expect
>> to get all of the tree unless paths are specified.
>
> Sorry about the late reply.  Would these two additional manpage lines
> clear things up for you?

While the updated description reflects what the command does more accurately, I am not sure if it is a desired behaviour. For one thing, --format=tar (by the way, maybe we would want to make this the default when none is specified?) adds the comment that is readable by get-tar-commit-id that claims the tarball contains the named commit, giving a false impression that it is the whole thing. Since people who _really_ want a subtree can just say "git archive --format=tar HEAD:Documentation", I suspect we may be better off not doing "current directory only" by default. This changes the behaviour, but (1) it affects only people who run from a subdirectory, (2) it is counterintuitive that your location in the working tree matters when you say "I want a tarball of that commit", and (3) it is an undocumented behaviour anyway.

So my suggestions are:
 (1) When no pathspec is given, archive the whole tree, even
     when you are in a subdirectory.
 (2) When a pathspec is given, produce a partial tarball limited
     to the named spec like we do now, but do not say it is a
     tarball of the named commit (i.e. get-tar-commit-id would
     say empty).

An alternative to (2) would be to say "$commit:Documentation" instead, but that has a little issue of what to do when more than one pathspecs are given.

Previous: René ScharfeNext: René Scharfe
Message 4 of 10 in “bug in git-archive?”
  1. Nick WilliamsMar 3, 2007
  2. Johannes SchindelinMar 3, 2007
  3. git-archive: document CWD effectRené Scharfe, Apr 8, 2007
  4. Junio C HamanoApr 8, 2007
  5. René ScharfeApr 9, 2007
  6. Junio C HamanoApr 9, 2007
  7. Andy ParkinsApr 9, 2007
  8. René ScharfeApr 10, 2007
  9. Junio C HamanoApr 10, 2007
  10. René ScharfeApr 11, 2007

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.