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

Re: [PATCH 1/3] git-gui: properly check for a bare repo

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 18, 2009, 17:16 UTC
Message-ID
<20090218171639.GE22848@spearce.org>
In-Reply-To
<1234144850-2903-2-git-send-email-giuseppe.bilotta@gmail.com>
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:
Show 23 quoted lines
> When bare repository handling is not enabled, check for a bare
> repository looking at the core.bare config option rather than refusing
> to operate with a git directory ending with .git.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
> ---
> I know I should have probably used something like
> git rev-parse --is-bare-repository instead, but I didn't feel like
> adding another git call. Is the config approach robust enough?
> 
>  git-gui/git-gui.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index e018e07..658a728 100755
> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -1071,7 +1071,7 @@ if {$_prefix ne {}} {
>  	}
>  	unset cdup
>  } elseif {![is_enabled bare]} {
> -	if {[lindex [file split $_gitdir] end] ne {.git}} {
> +	if {[is_config_true core.bare]} {

This doesn't work as you expect. Its a chicken-and-egg problem. We haven't read the config yet because we aren't sure that the $_gitdir really is a git directory. Consequently, core.bare is always false.

However, yes, in modern versions of git the core.bare setting in .git/config is *usually* accurate.

The only time it isn't is when its not present (really old repository which hasn't been re-init'd in a long time), or when the user does "mv .git ../foo.git" to create a bare repository from a non-bare one.

;-)
-- 
Shawn.
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 3 of 9 in “git-gui: generic and robust worktree/gitdir support”
  1. 0/3 git-gui: generic and robust worktree/gitdir supportGiuseppe Bilotta, Feb 9, 2009
  2. 1/3 git-gui: properly check for a bare repoGiuseppe Bilotta, Feb 9, 2009
  3. Shawn O. PearceFeb 18, 2009
  4. Giuseppe BilottaFeb 18, 2009
  5. Shawn O. PearceFeb 18, 2009
  6. 2/3 git-gui: use the actual worktreeGiuseppe Bilotta, Feb 9, 2009
  7. Shawn O. PearceFeb 18, 2009
  8. 3/3 git-gui: define correct GIT_DIR for gitkGiuseppe Bilotta, Feb 9, 2009
  9. Shawn O. PearceFeb 18, 2009

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.