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

Re: [BUG] bare repository detection does not work with aliases

From
Jeff King <peff@peff.net>
Date
Mar 8, 2013, 06:37 UTC
Message-ID
<20130308063756.GA29242@sigill.intra.peff.net>
In-Reply-To
<94c531c1-57a0-4464-9f30-3c63f0c1a056@email.android.com>
On Thu, Mar 07, 2013 at 10:27:04PM -0800, Junio C Hamano wrote:
> The $GIT_BARE idea sounds very sensible to me.

Unfortunately, it is not quite as simple as that. I just wrote up the patch, and it turns out that we are foiled by how core.bare is treated. If it is true, the repo is definitely bare. If it is false, that is only a hint for us.

So we cannot just look at is_bare_repository() after setup_git_directory runs. Because we are not "definitely bare", only "maybe bare", it returns false. We just happen not to have a work tree. We could do something like:

  if (is_bare_repository_cfg || !work_tree)
          setenv("GIT_BARE", "1", 1);

which I think would work, but feels kind of wrong. We are bare in this instance, but somebody setting GIT_WORK_TREE in a sub-process would want to become unbare, presumably, but our variable would override them.

Just looking through all of the code paths, I am getting a little nervous that I would not cover all the bases for such a $GIT_BARE to work (e.g., doing GIT_BARE=0 would not do I would expect as a user, because of the historical way we treat core.bare=false).

So rather than introduce something like $GIT_BARE which is going to bring about all new kinds of corner cases, I think I'd rather just pass along a $GIT_NO_IMPLICIT_WORK_TREE variable, which is much more direct for solving this problem, and is less likely to end up having bugs of its own.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 4 of 16 in “[BUG] bare repository detection does not work with aliases”
  1. Mark LodatoMar 7, 2013
  2. Jeff KingMar 8, 2013
  3. Junio C HamanoMar 8, 2013
  4. Jeff KingMar 8, 2013
  5. setup: suppress implicit "." work-tree for bare reposJeff King, Mar 8, 2013
  6. Johannes SixtMar 8, 2013
  7. Jeff KingMar 8, 2013
  8. Junio C HamanoMar 8, 2013
  9. Jeff KingMar 8, 2013
  10. [PATCHv2] setup and GIT_IMPLICIT_WORK_TREEJeff King, Mar 8, 2013
  11. 1/3 cache.h: drop LOCAL_REPO_ENV_SIZEJeff King, Mar 8, 2013
  12. 2/3 environment: add GIT_PREFIX to local_repo_envJeff King, Mar 8, 2013
  13. Eric SunshineMar 8, 2013
  14. Jeff KingMar 8, 2013
  15. Junio C HamanoMar 8, 2013
  16. 3/3 setup: suppress implicit "." work-tree for bare reposJeff King, Mar 8, 2013

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.