]> asedeno.scripts.mit.edu Git - git.git/blobdiff - lib/branch_delete.tcl
git-gui: Fix detaching current branch during checkout
[git.git] / lib / branch_delete.tcl
index 16ca6938bec5c93f189e3a63eb0c6cd44ed9503b..c7573c6c7215cd4cd11f322ae3dba5b77b938078 100644 (file)
@@ -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"
@@ -40,6 +40,7 @@ constructor dialog {} {
                -height 10 \
                -width 70 \
                -selectmode extended \
+               -exportselection false \
                -yscrollcommand [list $w.list.sby set]
        scrollbar $w.list.sby -command [list $w.list.l yview]
        pack $w.list.sby -side right -fill y
@@ -53,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
                }
@@ -78,15 +79,7 @@ method _select {} {
 }
 
 method _delete {} {
-       global all_heads
-
-       if {[catch {set check_cmt [$w_check get_commit]} err]} {
-               tk_messageBox \
-                       -icon error \
-                       -type ok \
-                       -title [wm title $w] \
-                       -parent $w \
-                       -message "Invalid revision: [$w_check get]"
+       if {[catch {set check_cmt [$w_check commit_or_die]}]} {
                return
        }
 
@@ -138,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]
-                       }
                }
        }
 
@@ -155,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
 }