git-gui: Refactor branch switch to support detached head
[git/libgit-gsoc.git] / lib / branch.tcl
blobb948d926ae29ff649390e97dea522f32381e7d55
1 # git-gui branch (create/delete) support
2 # Copyright (C) 2006, 2007 Shawn Pearce
4 proc load_all_heads {} {
5 global some_heads_tracking
7 set rh refs/heads
8 set rh_len [expr {[string length $rh] + 1}]
9 set all_heads [list]
10 set fd [open "| git for-each-ref --format=%(refname) $rh" r]
11 while {[gets $fd line] > 0} {
12 if {!$some_heads_tracking || ![is_tracking_branch $line]} {
13 lappend all_heads [string range $line $rh_len end]
16 close $fd
18 return [lsort $all_heads]
21 proc load_all_tags {} {
22 set all_tags [list]
23 set fd [open "| git for-each-ref --sort=-taggerdate --format=%(refname) refs/tags" r]
24 while {[gets $fd line] > 0} {
25 if {![regsub ^refs/tags/ $line {} name]} continue
26 lappend all_tags $name
28 close $fd
29 return $all_tags
32 proc radio_selector {varname value args} {
33 upvar #0 $varname var
34 set var $value