path: root/lib/branch_delete.tcl
diff options
authorShawn O. Pearce <>2007-07-08 22:40:56 (GMT)
committerShawn O. Pearce <>2007-07-09 02:34:46 (GMT)
commitd41b43eb4c73044d0fff2057211fc78e4e7b2094 (patch)
treeebab56d146f4cafef1b1adf740949403329f71ea /lib/branch_delete.tcl
parent699d5601f59938d62ec2506f319c25a656a403da (diff)
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 <>
Diffstat (limited to 'lib/branch_delete.tcl')
1 files changed, 2 insertions, 11 deletions
diff --git a/lib/branch_delete.tcl b/lib/branch_delete.tcl
index 138e841..c7573c6 100644
--- a/lib/branch_delete.tcl
+++ b/lib/branch_delete.tcl
@@ -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]}]} {
@@ -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