1
0
mirror of https://github.com/git/git.git synced 2024-11-18 19:43:50 +01:00

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 <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2007-01-21 04:51:45 -05:00
parent 6858efbda3
commit 4f9d8519fb

@ -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 {}