From 4f9d8519fb3297063392d0268c0430fe5a6a02f1 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 21 Jan 2007 04:51:45 -0500 Subject: [PATCH] git-gui: Improve the branch delete confirmation dialogs. If the user is deleting a branch which is fully merged into the selected test branch we should not confirm the delete with them, the fact that the branch is fully merged means we can recover the branch and no work will be lost. If a branch is not fully merged, we should warn the user about which branch(es) that is and continue deleting those which are fully merged. We should only delete a branch if the user disables the merge check, and in that case we should confirm with the user that a delete should occur as this may cause them to lose changes. Signed-off-by: Shawn O. Pearce --- git-gui.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index e4676bf79..c9143973d 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1811,43 +1811,43 @@ proc do_delete_branch_action {w} { global delete_branch_checkhead delete_branch_head set to_delete [list] - set msg {Are you sure you want to delete the following branches? - -} + set not_merged [list] foreach i [$w.list.l curselection] { set b [$w.list.l get $i] if {[catch {set o [exec git rev-parse --verify $b]}]} continue if {$delete_branch_checkhead} { if {[catch {set m [exec git merge-base $o $delete_branch_head]}]} continue - if {$o ne $m} continue + if {$o ne $m} { + lappend not_merged $b + continue + } } lappend to_delete [list $b $o] - append msg " - $b\n" } - if {$to_delete eq {}} { + if {$not_merged ne {}} { + set msg "The following branches are not completely merged into $delete_branch_head: + + - [join $not_merged "\n - "]" tk_messageBox \ -icon info \ -type ok \ -title [wm title $w] \ -parent $w \ - -message {No branches are able to be deleted. - -This is likely because you did not select any branches, -or all selected branches are not completely merged. -} - return + -message $msg } - append msg { -It can be difficult to recover deleted branches. + if {$to_delete eq {}} return + if {!$delete_branch_checkhead} { + set msg {Recovering deleted branches is difficult. -Delete the above branches?} - if {[tk_messageBox \ - -icon warning \ - -type yesno \ - -title [wm title $w] \ - -parent $w \ - -message $msg] ne yes} { - return +Delete the selected branches?} + if {[tk_messageBox \ + -icon warning \ + -type yesno \ + -title [wm title $w] \ + -parent $w \ + -message $msg] ne yes} { + return + } } set failed {} -- 2.26.2