[PATCH v7 0/3] git-gui: robustify startup and fix environment handling
- From
- Shroom Moo <egg_mushroomcow@foxmail.com>
- Date
- May 9, 2026, 13:37 UTC
- Message-ID
- <tencent_66A1C2CDB9D5B764A5B4468D3F11845A2A09@qq.com>
- In-Reply-To
- <tencent_DDD6467B3F6184562B51C23BB9DBB79EA409@qq.com>
This series addresses the startup crash introduced by Git commit "2d92ab32fd ("rev-parse: make --show-toplevel without a worktree an error", 2019-11-19)", which causes `git gui` to die with a Tcl error when a worktree is missing (e.g. inside a .git directory without a working tree, or in a bare repository).
Additionally, it resolves two historically inconsistent behaviours: - The "Visualize ... History" menu items were enabled in bare repositories but triggered Tcl errors due to the missing worktree. - `GIT_WORK_TREE` and `GIT_DIR` environment variables were not respected early enough, so `GIT_WORK_TREE=/some/path git gui` often ignored the explicit worktree and brought up the repository picker, and an exported empty `GIT_WORK_TREE` confused commands like `git branch --show-current` in bare repositories.
Shroom Moo (3): git-gui: restructure repository startup git-gui: disable gitk visualization when no worktree available git-gui: handle GIT_DIR and GIT_WORK_TREE early
git-gui/git-gui.sh | 187 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 141 insertions(+), 46 deletions(-)
-- 2.52.0.windows.1