mirror of
https://github.com/git/git.git
synced 2026-08-13 06:31:17 +00:00
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>
This commit is contained in:
23
git-gui.sh
23
git-gui.sh
@@ -744,27 +744,8 @@ proc sq {value} {
|
|||||||
proc load_current_branch {} {
|
proc load_current_branch {} {
|
||||||
global current_branch is_detached
|
global current_branch is_detached
|
||||||
|
|
||||||
set fd [safe_open_file [gitdir HEAD] r]
|
set current_branch [git branch --show-current]
|
||||||
fconfigure $fd -translation binary -encoding utf-8
|
set is_detached [expr [string length $current_branch] == 0]
|
||||||
if {[gets $fd ref] < 1} {
|
|
||||||
set ref {}
|
|
||||||
}
|
|
||||||
close $fd
|
|
||||||
|
|
||||||
set pfx {ref: refs/heads/}
|
|
||||||
set len [string length $pfx]
|
|
||||||
if {[string equal -length $len $pfx $ref]} {
|
|
||||||
# We're on a branch. It might not exist. But
|
|
||||||
# HEAD looks good enough to be a branch.
|
|
||||||
#
|
|
||||||
set current_branch [string range $ref $len end]
|
|
||||||
set is_detached 0
|
|
||||||
} else {
|
|
||||||
# Assume this is a detached head.
|
|
||||||
#
|
|
||||||
set current_branch HEAD
|
|
||||||
set is_detached 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_load tk_optionMenu
|
auto_load tk_optionMenu
|
||||||
|
|||||||
Reference in New Issue
Block a user