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

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

From
APAndy Parkins <andyparkins@gmail.com>
Date
Apr 9, 2007, 20:37 UTC
Message-ID
<200704092137.22781.andyparkins@gmail.com>
In-Reply-To
<461A55FB.6070600@lsrfire.ath.cx>
On Monday 2007, April 09, René Scharfe wrote:
Show 8 quoted lines
> I agree with (1) and (3), meaning that we are free to change the
> behaviour.  I don't agree with (2), though.  I'd find it strange if
> changing the working directory wouldn't change the archive contents.
>
> We should keep consistency with the rest of git here.  Since
> git-archive is just a fancy git-ls-tree, I think we should mirror its
> behaviour with respect to the working directory.  (Which is what the
> current code does. Modulo bugs, of course.)

I don't agree with the supposition that git-archive is a fancy git-ls-tree. If it were, then you'd be right. It's not though. It's more like a git-read-tree or git-checkout-index; those both don't care where you are in the working tree.

Argument 1) git-archive should have nothing to do with a working tree in fact; it's perfectly reasonable to expect that it would work in a bare repository in fact - that's almost the definition of a command that shouldn't be working directory aware.

Argument 2) Consider the --remote option. What "working path" should be relevant when "--remote" is passed? For consistency, git-archive should always refer to the repository root.

Argument 3) git-archive is similar to other VCS's "export" command; and for those the export command in it's default form will work without a local checkout and they export from the repository root.

Argument 4) What if the repository has multiple root commits, similar to git's html and todo branches. Now, use git-archive and reference one of those commits. The working directory you're in now has no relevance at all to the commit your targeting - it need not even exist. The same problem exists of course if you are now in a directory that didn't exist in the past.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Junio C HamanoNext: René Scharfe
Message 7 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.