Skip to contentSkip to conversation

gitk: show detached HEAD if --all is specified

PATCH In review Max Kirillov 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: show detached HEAD if --all is specified

If HEAD is detached, 'gitk --all' does not show it. This is inconvenient for frontend program, and for example git log does show the detached HEAD.

gitk uses git rev-parse to find a list of branches to show. Apparently, the command does not include detached HEAD to output if --all argument is specified. This has been discussed in [1] and stated as expected behavior. So rev-parse's parameters should be tuned in gitk.

[1] http://thread.gmane.org/gmane.comp.version-control.git/255996

---
 gitk | 2 ++
 1 file changed, 2 insertions(+)
gitk +2 -0
index c8df35d..a5d98bf 100755
@@ -294,6 +294,8 @@ proc parseviewrevs {view revs} {
 
     if {$revs eq {}} {
 	set revs HEAD
+    } elseif {[lsearch -exact $revs --all] >= 0} {
+	lappend revs HEAD
     }
     if {[catch {set ids [eval exec git rev-parse $revs]} err]} {
 	# we get stdout followed by stderr in $err
Signature · 1 line
2.0.1.1697.g73c6810
#1 lore raw
Quoted 2 lines · Max Kirillov

If HEAD is detached, 'gitk --all' does not show it. This is inconvenient for frontend program, and for example git log does show the detached HEAD.

"git log" does use the same revision machinery as rev-parse uses internally to parse its command line arguments. What does it do differently?

#2 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 2 lines · Max Kirillov

If HEAD is detached, 'gitk --all' does not show it. This is inconvenient for frontend program, and for example git log does show the detached HEAD.

"git log" does use the same revision machinery as rev-parse uses internally to parse its command line arguments. What does it do differently?

Ah, nevermind. I misremembered that rev-parse does not use the revision machinery.