@matheusbsbs / matheus-bagliano / commits / 9c10deab6c
Fork 0

git-gui: Correctly categorize tracking branches and heads.

Up until now git-gui did not support the new wildcard syntax used to fetch any remote branch into a tracking branch during 'git fetch'. Now if we identify a tracking branch as ending with the string '/*' then we use for-each-ref to print out the reference names which may have been fetched by that pattern. We also now correctly filter any tracking branches out of refs/heads, if they user has placed any there. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 21, 2007 at 17:22 UTC 9c10deab6ceb15b6b576d9bc77955c24d5baa709
1 file changed +36 -10
git-gui.sh
+36 -10
@@ -1629,16 +1629,27 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
1629 ##
1630 ## branch management
1631
1632 +proc is_tracking_branch {name} {
1633 + global tracking_branches
1634 +
1635 + if {![catch {set info $tracking_branches($name)}]} {
1636 + return 1
1637 + }
1638 + foreach t [array names tracking_branches] {
1639 + if {[string match {*/\*} $t] && [string match $t $name]} {
1640 + return 1
1641 + }
1642 + }
1643 + return 0
1644 +}
1645 +
1646 proc load_all_heads {} {
1633 - global all_heads tracking_branches
1647 + global all_heads
1648
1649 set all_heads [list]
1636 - set cmd [list git for-each-ref]
1637 - lappend cmd --format=%(refname)
1638 - lappend cmd refs/heads
1639 - set fd [open "| $cmd" r]
1650 + set fd [open "| git for-each-ref --format=%(refname) refs/heads" r]
1651 while {[gets $fd line] > 0} {
1641 - if {![catch {set info $tracking_branches($line)}]} continue
1652 + if {[is_tracking_branch $line]} continue
1653 if {![regsub ^refs/heads/ $line {} name]} continue
1654 lappend all_heads $name
1655 }
@@ -1682,11 +1693,26 @@ proc populate_branch_menu {} {
1693 proc all_tracking_branches {} {
1694 global tracking_branches
1695
1685 - set all_trackings [list]
1686 - foreach b [array names tracking_branches] {
1687 - regsub ^refs/(heads|remotes)/ $b {} b
1688 - lappend all_trackings $b
1696 + set all_trackings {}
1697 + set cmd {}
1698 + foreach name [array names tracking_branches] {
1699 + if {[regsub {/\*$} $name {} name]} {
1700 + lappend cmd $name
1701 + } else {
1702 + regsub ^refs/(heads|remotes)/ $name {} name
1703 + lappend all_trackings $name
1704 + }
1705 + }
1706 +
1707 + if {$cmd ne {}} {
1708 + set fd [open "| git for-each-ref --format=%(refname) $cmd" r]
1709 + while {[gets $fd name] > 0} {
1710 + regsub ^refs/(heads|remotes)/ $name {} name
1711 + lappend all_trackings $name
1712 + }
1713 + close $fd
1714 }
1715 +
1716 return [lsort -unique $all_trackings]
1717 }
1718