Re: [PATCH v3 1/1] git-gui: handle missing worktree and separated gitdir
- From
Mark Levedahl <mlevedahl@gmail.com>
- Date
- May 5, 2026, 03:40 UTC
- Message-ID
- <f01d89c0-12ae-43b0-84a5-9e4132f584f8@gmail.com>
- In-Reply-To
- <7d5cf952-badb-4071-a0eb-af9443fa8b5b@gmail.com>
Show 11 quoted lines
> > 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