git-gui: simplify [is_bare] to report if a worktree is known

git-gui includes proc is_bare, used in several places to make decisions on whether a worktree exists, but also in discovery to tell if a worktree can be supported. But, is_bare is out of date with regard to multiple worktrees, safe repository guards, and possibly other relevant features known to git rev-parse. Also, is_bare caches its result on the first call, so is not useful if a later step in the discovery process finds a worktree. So, simplify is_bare to report whether git-gui has a worktree or is working only from a repository. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>

Mark Levedahl committed May 31, 2026 at 19:02 UTC d0e9b4959bea9f4bfca2628eb24136b23c00e8fa
1 file changed +1 -24
git-gui.sh
+1 -24
@@ -372,7 +372,6 @@ if {[tk windowingsystem] eq "aqua"} {
372 set _appname {Git Gui}
373 set _gitdir {}
374 set _gitworktree {}
375 -set _isbare {}
375 set _githtmldir {}
376 set _prefix {}
377 set _reponame {}
@@ -524,29 +523,7 @@ proc get_config {name} {
523 }
524
525 proc is_bare {} {
527 - global _isbare
528 - global _gitdir
529 - global _gitworktree
530 -
531 - if {$_isbare eq {}} {
532 - if {[catch {
533 - set _bare [git rev-parse --is-bare-repository]
534 - switch -- $_bare {
535 - true { set _isbare 1 }
536 - false { set _isbare 0}
537 - default { throw }
538 - }
539 - }]} {
540 - if {[is_config_true core.bare]
541 - || ($_gitworktree eq {}
542 - && [lindex [file split $_gitdir] end] ne {.git})} {
543 - set _isbare 1
544 - } else {
545 - set _isbare 0
546 - }
547 - }
548 - }
549 - return $_isbare
526 + return [expr {$::_gitworktree eq {}}]
527 }
528
529 ######################################################################