git-gui: use git-branch --show-current
git-gui relies upon the files back-end to determine the current branch. This does not support the newer reftables backend. But, git-branch has long supported --show-current to get this same information regardless of backend cahnged. So teach git-gui to use git-branch --show-current. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Mark Levedahl committed
Feb 12, 2024 at 14:42 UTC
f87a36b697ca7a9415fa8773a06d943d84db1b80
1 file changed
+2
-21
git-gui.sh
+2
-21
@@ -744,27 +744,8 @@ proc sq {value} {
744
proc load_current_branch {} {
745
global current_branch is_detached
746
747
- set fd [safe_open_file [gitdir HEAD] r]
748
- fconfigure $fd -translation binary -encoding utf-8
749
- if {[gets $fd ref] < 1} {
750
- set ref {}
751
- }
752
- close $fd
753
-
754
- set pfx {ref: refs/heads/}
755
- set len [string length $pfx]
756
- if {[string equal -length $len $pfx $ref]} {
757
- # We're on a branch. It might not exist. But
758
- # HEAD looks good enough to be a branch.
759
- #
760
- set current_branch [string range $ref $len end]
761
- set is_detached 0
762
- } else {
763
- # Assume this is a detached head.
764
- #
765
- set current_branch HEAD
766
- set is_detached 1
767
- }
747
+ set current_branch [git branch --show-current]
748
+ set is_detached [expr [string length $current_branch] == 0]
749
}
750
751
auto_load tk_optionMenu