Skip to content

Commit f87a36b

Browse files
committed
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 <[email protected]>
1 parent d342dcd commit f87a36b

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

git-gui.sh

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -744,27 +744,8 @@ proc sq {value} {
744744
proc load_current_branch {} {
745745
global current_branch is_detached
746746

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]
768749
}
769750

770751
auto_load tk_optionMenu

0 commit comments

Comments
 (0)