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

Re: [RFC/PATCH 4/4] Disallow working directory commands in a bare repository.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 31, 2006, 05:33 UTC
Message-ID
<7virfsk4sd.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061231043238.GD5823@spearce.org>
I think the intent is good.

But execution has room for improvement, and it is not your fault. The shell script version of require_not_bare is as fragile as is_bare_git_dir(), which I already do not like, and I think if we are going to use is_bare_git_dir() more, I think we would want to have something a bit more robust.

If we could outlaw $GIT_DIR/index in a bare repository, then lack of $GIT_DIR/index combined with nonexistence of ref that is pointed at by $GIT_DIR/HEAD could become a good indication that the repository is bare ("the current branch unborn" check is needed not to mistake a repository before the initial commit as a bare one).

Alas, many public repositories you would see (e.g. check kernel.org) have been primed with rsync of .git/ from developer's working repository and have leftover index that is otherwise unused. Because of this heavy historical baggage, I suspect that it is rather hard to convince people to allow us to use this technique.

When you have $GIT_DIR in your environment, no working-tree command is expected to work unless you are at the toplevel of the working-tree. In the past, people talked about their workflows using more than one working trees that are associated with a single $GIT_DIR and that is certainly supposed to work. But I wonder how widely such a set-up is employed in practice. If we outlawed working-tree commands when $GIT_DIR environment exists, how much hurt are we talking about, I wonder.

Another thing to think about is if we are happy with the above restriction that makes environment $GIT_DIR to imply you are always working at the toplevel. Maybe it could be a good idea to kill this bird as well by introducing $GIT_WORKTREE_TOP environment variable. Presence of it obviously means we are not in a bare repository, but at the same time it would allow us to teach setup_git_directory_gentry() to cd up to that directory to make the commands behave as expected.

Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 11 of 17 in “Replace "GIT_DIR" with GIT_DIR_ENVIRONMENT.”
  1. 2/4 Replace "GIT_DIR" with GIT_DIR_ENVIRONMENT.Shawn O. Pearce, Dec 31, 2006
  2. 3/4 Automatically detect a bare git repository.Shawn O. Pearce, Dec 31, 2006
  3. Junio C HamanoDec 31, 2006
  4. Shawn PearceDec 31, 2006
  5. Junio C HamanoDec 31, 2006
  6. Theodore TsoDec 31, 2006
  7. Shawn O. PearceJan 1, 2007
  8. Martin WaitzDec 31, 2006
  9. Shawn O. PearceJan 1, 2007
  10. 4/4 Disallow working directory commands in a bare repository.Shawn O. Pearce, Dec 31, 2006
  11. Junio C HamanoDec 31, 2006
  12. Shawn O. PearceDec 31, 2006
  13. Junio C HamanoDec 31, 2006
  14. Theodore TsoDec 31, 2006
  15. Johannes SchindelinDec 31, 2006
  16. Junio C HamanoDec 31, 2006
  17. Johannes SchindelinJan 2, 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.