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

Re: [RFC PATCH] archive: fix setup to work in bare repositories

From
Jeff King <peff@peff.net>
Date
Oct 22, 2008, 20:46 UTC
Message-ID
<20081022204650.GD4585@coredump.intra.peff.net>
In-Reply-To
<20081022203722.GD2015@riemann.deskinm.fdns.net>
On Wed, Oct 22, 2008 at 04:37:22PM -0400, Deskin Miller wrote:
Show 8 quoted lines
> cmd_archive was calling git_config -> setup_git_env prior to
> write_archive calling setup_git_directory.  In a bare repository, the
> former will set git_dir to be '.git' since the latter has not
> determined that it's operating in a bare repository yet.
> 
> Things are complicated, however, by the fact that git archive --list
> should work from anywhere, not just in git repositories, so that
> argument needs to be checked for before setup_git_directory is called.

Should you perhaps be able to call setup_git_directory_gently(), and then once you decide that you really do need the setup, call setup_git_directory()?

You would have to add a "did we already do run" flag to setup_git_directory_gently(), but I think it is already an error to call it twice, so you wouldn't be hurting anything by that.

Note also that by moving the setup, you are moving the chdir() that happens; you may need to prefix paths to any arguments to accomodate this (I don't think it should matter, since git-archive shouldn't look at any paths until after it would have done the setup_git_directory() before, but I didn't check carefully).

-Peff
Previous: Deskin MillerNext: Charles Bailey
Message 5 of 14 in “git archive”
  1. kenneth johanssonOct 22, 2008
  2. Deskin MillerOct 22, 2008
  3. kenneth johanssonOct 22, 2008
  4. archive: fix setup to work in bare repositoriesDeskin Miller, Oct 22, 2008
  5. Jeff KingOct 22, 2008
  6. Charles BaileyOct 22, 2008
  7. Fixed git archive for bare reposCharles Bailey, Oct 22, 2008
  8. Deskin MillerOct 23, 2008
  9. René ScharfeOct 24, 2008
  10. Fixed git archive for bare reposDeskin Miller, Oct 25, 2008
  11. Junio C HamanoOct 25, 2008
  12. Nguyen Thai Ngoc DuyOct 23, 2008
  13. Deskin MillerOct 23, 2008
  14. Nguyen Thai Ngoc DuyOct 24, 2008

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.