[PATCH v6 0/3] git-gui: robustify startup and fix environment handling
- From
- Shroom Moo <egg_mushroomcow@foxmail.com>
- Date
- May 6, 2026, 20:27 UTC
- Message-ID
- <tencent_DDD6467B3F6184562B51C23BB9DBB79EA409@qq.com>
- In-Reply-To
- <tencent_78B80FB7A0A42E464B3EF1841E2AF3C39509@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 | 170 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 128 insertions(+), 42 deletions(-)
-- 2.52.0.windows.1