Code

git-gui: Maintain remote and source ref for tracking branches
[git.git] / lib / branch.tcl
index e56f674c6dc3348d9ee9e23e8424947fa4a321e7..de638d02e8023636e4198d5546e1eb3ac6f6ab32 100644 (file)
@@ -3,13 +3,16 @@
 
 proc load_all_heads {} {
        global all_heads
+       global some_heads_tracking
 
+       set rh refs/heads
+       set rh_len [expr {[string length $rh] + 1}]
        set all_heads [list]
-       set fd [open "| git for-each-ref --format=%(refname) refs/heads" r]
+       set fd [open "| git for-each-ref --format=%(refname) $rh" r]
        while {[gets $fd line] > 0} {
-               if {[is_tracking_branch $line]} continue
-               if {![regsub ^refs/heads/ $line {} name]} continue
-               lappend all_heads $name
+               if {!$some_heads_tracking || ![is_tracking_branch $line]} {
+                       lappend all_heads [string range $line $rh_len end]
+               }
        }
        close $fd