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>
This commit is contained in:
parent
4343434307
commit
9c10deab6c
46
git-gui.sh
46
git-gui.sh
@ -1629,16 +1629,27 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
|
|||||||
##
|
##
|
||||||
## branch management
|
## branch management
|
||||||
|
|
||||||
|
proc is_tracking_branch {name} {
|
||||||
|
global tracking_branches
|
||||||
|
|
||||||
|
if {![catch {set info $tracking_branches($name)}]} {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
foreach t [array names tracking_branches] {
|
||||||
|
if {[string match {*/\*} $t] && [string match $t $name]} {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
proc load_all_heads {} {
|
proc load_all_heads {} {
|
||||||
global all_heads tracking_branches
|
global all_heads
|
||||||
|
|
||||||
set all_heads [list]
|
set all_heads [list]
|
||||||
set cmd [list git for-each-ref]
|
set fd [open "| git for-each-ref --format=%(refname) refs/heads" r]
|
||||||
lappend cmd --format=%(refname)
|
|
||||||
lappend cmd refs/heads
|
|
||||||
set fd [open "| $cmd" r]
|
|
||||||
while {[gets $fd line] > 0} {
|
while {[gets $fd line] > 0} {
|
||||||
if {![catch {set info $tracking_branches($line)}]} continue
|
if {[is_tracking_branch $line]} continue
|
||||||
if {![regsub ^refs/heads/ $line {} name]} continue
|
if {![regsub ^refs/heads/ $line {} name]} continue
|
||||||
lappend all_heads $name
|
lappend all_heads $name
|
||||||
}
|
}
|
||||||
@ -1682,11 +1693,26 @@ proc populate_branch_menu {} {
|
|||||||
proc all_tracking_branches {} {
|
proc all_tracking_branches {} {
|
||||||
global tracking_branches
|
global tracking_branches
|
||||||
|
|
||||||
set all_trackings [list]
|
set all_trackings {}
|
||||||
foreach b [array names tracking_branches] {
|
set cmd {}
|
||||||
regsub ^refs/(heads|remotes)/ $b {} b
|
foreach name [array names tracking_branches] {
|
||||||
lappend all_trackings $b
|
if {[regsub {/\*$} $name {} name]} {
|
||||||
|
lappend cmd $name
|
||||||
|
} else {
|
||||||
|
regsub ^refs/(heads|remotes)/ $name {} name
|
||||||
|
lappend all_trackings $name
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$cmd ne {}} {
|
||||||
|
set fd [open "| git for-each-ref --format=%(refname) $cmd" r]
|
||||||
|
while {[gets $fd name] > 0} {
|
||||||
|
regsub ^refs/(heads|remotes)/ $name {} name
|
||||||
|
lappend all_trackings $name
|
||||||
|
}
|
||||||
|
close $fd
|
||||||
|
}
|
||||||
|
|
||||||
return [lsort -unique $all_trackings]
|
return [lsort -unique $all_trackings]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user