@matheusbsbs / matheus-bagliano / commits / 4f9d8519fb
Fork 0

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>

Shawn O. Pearce committed Jan 21, 2007 at 04:51 UTC 4f9d8519fb3297063392d0268c0430fe5a6a02f1
1 file changed +22 -22
git-gui.sh
+22 -22
@@ -1811,43 +1811,43 @@ proc do_delete_branch_action {w} {
1811 global delete_branch_checkhead delete_branch_head
1812
1813 set to_delete [list]
1814 - set msg {Are you sure you want to delete the following branches?
1815 -
1816 -}
1814 + set not_merged [list]
1815 foreach i [$w.list.l curselection] {
1816 set b [$w.list.l get $i]
1817 if {[catch {set o [exec git rev-parse --verify $b]}]} continue
1818 if {$delete_branch_checkhead} {
1819 if {[catch {set m [exec git merge-base $o $delete_branch_head]}]} continue
1822 - if {$o ne $m} continue
1820 + if {$o ne $m} {
1821 + lappend not_merged $b
1822 + continue
1823 + }
1824 }
1825 lappend to_delete [list $b $o]
1825 - append msg " - $b\n"
1826 }
1827 - if {$to_delete eq {}} {
1827 + if {$not_merged ne {}} {
1828 + set msg "The following branches are not completely merged into $delete_branch_head:
1829 +
1830 + - [join $not_merged "\n - "]"
1831 tk_messageBox \
1832 -icon info \
1833 -type ok \
1834 -title [wm title $w] \
1835 -parent $w \
1833 - -message {No branches are able to be deleted.
1834 -
1835 -This is likely because you did not select any branches,
1836 -or all selected branches are not completely merged.
1837 -}
1838 - return
1836 + -message $msg
1837 }
1840 - append msg {
1841 -It can be difficult to recover deleted branches.
1838 + if {$to_delete eq {}} return
1839 + if {!$delete_branch_checkhead} {
1840 + set msg {Recovering deleted branches is difficult.
1841
1843 -Delete the above branches?}
1844 - if {[tk_messageBox \
1845 - -icon warning \
1846 - -type yesno \
1847 - -title [wm title $w] \
1848 - -parent $w \
1849 - -message $msg] ne yes} {
1850 - return
1842 +Delete the selected branches?}
1843 + if {[tk_messageBox \
1844 + -icon warning \
1845 + -type yesno \
1846 + -title [wm title $w] \
1847 + -parent $w \
1848 + -message $msg] ne yes} {
1849 + return
1850 + }
1851 }
1852
1853 set failed {}