git-gui: Refactor branch switch to support detached head
This is a major rewrite of the way we perform switching between branches and the subsequent update of the working directory. Like core Git we now use a single code path to perform all changes: our new checkout_op class. We also use it for branch creation/update as it integrates the tracking branch fetch process along with a very basic merge (fast-forward and reset only currently). Because some users have literally hundreds of local branches we use the standard revision picker (with its branch filtering tool) to select the local branch, rather than keeping all of the local branches in the Branch menu. The branch menu listing out all of the available branches is simply not sane for those types of huge repositories. Users can now checkout a detached head by ticking off the option in the checkout dialog. This option is off by default for the obvious reason, but it can be easily enabled for any local branch by simply checking it. We also detach the head if any non local branch was selected, or if a revision expression was entered. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
@ -9,7 +9,7 @@ field w_check ; # revision picker for merge test
|
||||
field w_delete ; # delete button
|
||||
|
||||
constructor dialog {} {
|
||||
global all_heads current_branch
|
||||
global current_branch
|
||||
|
||||
make_toplevel top w
|
||||
wm title $top "[appname] ([reponame]): Delete Branch"
|
||||
@ -54,7 +54,7 @@ constructor dialog {} {
|
||||
$w_check none {Always (Do not perform merge test.)}
|
||||
pack $w.check -anchor nw -fill x -pady 5 -padx 5
|
||||
|
||||
foreach h $all_heads {
|
||||
foreach h [load_all_heads] {
|
||||
if {$h ne $current_branch} {
|
||||
$w_heads insert end $h
|
||||
}
|
||||
@ -79,8 +79,6 @@ method _select {} {
|
||||
}
|
||||
|
||||
method _delete {} {
|
||||
global all_heads
|
||||
|
||||
if {[catch {set check_cmt [$w_check commit_or_die]}]} {
|
||||
return
|
||||
}
|
||||
@ -133,11 +131,6 @@ Delete the selected branches?}
|
||||
set o [lindex $i 1]
|
||||
if {[catch {git update-ref -d "refs/heads/$b" $o} err]} {
|
||||
append failed " - $b: $err\n"
|
||||
} else {
|
||||
set x [lsearch -sorted -exact $all_heads $b]
|
||||
if {$x >= 0} {
|
||||
set all_heads [lreplace $all_heads $x $x]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,8 +143,6 @@ Delete the selected branches?}
|
||||
-message "Failed to delete branches:\n$failed"
|
||||
}
|
||||
|
||||
set all_heads [lsort $all_heads]
|
||||
populate_branch_menu
|
||||
destroy $w
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user