]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: use HEAD as current branch when detached
authorMark Levedahl <mlevedahl@gmail.com>
Sun, 31 May 2026 23:02:14 +0000 (19:02 -0400)
committerJohannes Sixt <j6t@kdbg.org>
Mon, 1 Jun 2026 07:44:45 +0000 (09:44 +0200)
commit f87a36b697 ("git-gui: use git-branch --show-current", 2024-02-12)
changed git-gui to use git-branch to access refs, rather than directly
reading files as doing the latter is not compatible with the reftable
backend. git branch --show-current reports an empty branch name when the
head is detached, and in this case load_current_branch needs to report
HEAD using special case logic as it did prior to the above commit. Make
it do so.

This addresses an issue with git-gui browser failing with a detached
head.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
git-gui.sh

index 23fe76e498bd17b4b37f2be6748a40f4bb8e9a1f..f70a54a61b26647da10efcdaddfcc1d73e0d6c8e 100755 (executable)
@@ -670,6 +670,9 @@ proc load_current_branch {} {
 
        set current_branch [git branch --show-current]
        set is_detached [expr [string length $current_branch] == 0]
+       if {$is_detached} {
+               set current_branch {HEAD}
+       }
 }
 
 auto_load tk_optionMenu