aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Levedahl <mlevedahl@gmail.com>2024-02-12 14:42:05 -0500
committerMark Levedahl <mlevedahl@gmail.com>2025-07-18 23:48:06 -0400
commitf87a36b697ca7a9415fa8773a06d943d84db1b80 (patch)
tree5b756a70488171d5209f2bf48582364333b284f2
parentd342dcddcf46ffdaa41d6736c9f7657fd54d4125 (diff)
downloadgit-f87a36b697ca7a9415fa8773a06d943d84db1b80.tar.gz
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>
-rwxr-xr-xgit-gui.sh23
1 files changed, 2 insertions, 21 deletions
diff --git a/git-gui.sh b/git-gui.sh
index f438c89bed..0347d488a7 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -744,27 +744,8 @@ proc sq {value} {
proc load_current_branch {} {
global current_branch is_detached
- set fd [safe_open_file [gitdir HEAD] r]
- fconfigure $fd -translation binary -encoding utf-8
- 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
- }
+ set current_branch [git branch --show-current]
+ set is_detached [expr [string length $current_branch] == 0]
}
auto_load tk_optionMenu