Subject: Re: [PATCH v3 1/1] git-gui: handle missing worktree and separated gitdir

From: Mark Levedahl <[email-masked]>
Date: Mon, 4 May 2026 23:40:50 -0400

>
> On 5/3/26 4:53 AM, Johannes Sixt wrote:
>> But perhaps there is a simpler solution: Let's present an error if
>> --show-toplevel fails except in the case where the startup directory is
>> named '.git' (and is a valid Git repository) and is not bare (then the
>> worktree is the parent). I insist in this exception, because this
>> use-case was considered important in the past (87cd09f43e56 "git-gui:
>> work from the .git dir", 2010-01-23).
>>
>> -- Hannes
>>

I've restructured startup code in line with what I suggested before, allowing operation in
a worktree or a gitdir, and with various combinations of GIT_DIR and GIT_WORK_TREE
environment variables set. Unfortunately, git-gui's blame and browser commands simply do
not now work without a valid worktree. The error(s) are not obvious to me, and bisecting
requires git version 2.24 or earlier to remove 2d92ab32fd ("rev-parse: make
--show-toplevel without a worktree an error", 2019-11-19) to even start: many gcc and
git/git-gui version compatibility issues are certain to arise. I won't be doing this.

So, I believe your suggestion above is the best path, leaving behind dead code that
purports to support operation from a gitdir but does not.

Mark