@matheusbsbs / matheus-bagliano / commits / bee866fa6b
Fork 0

gitk: Allow forcing branch creation if it already exists

If gitk knows that the branch the user tries to create exists, it should ask whether it should overwrite it. This way the user can either decide to choose a new name, or move the head while preserving the reflog. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Oct 8, 2008 at 11:05 UTC bee866fa6b5a77f65d9915f8778919ef76d9d6c1
1 file changed +23 -5
gitk
+23 -5
@@ -7727,24 +7727,42 @@ proc mkbrgo {top} {
7727
7728 set name [$top.name get]
7729 set id [$top.sha1 get]
7730 + set cmdargs {}
7731 + set old_id {}
7732 if {$name eq {}} {
7733 error_popup [mc "Please specify a name for the new branch"]
7734 return
7735 }
7736 + if {[info exists headids($name)]} {
7737 + if {![confirm_popup [mc \
7738 + "Branch '%s' already exists. Overwrite?" $name]]} {
7739 + return
7740 + }
7741 + set old_id $headids($name)
7742 + lappend cmdargs -f
7743 + }
7744 catch {destroy $top}
7745 + lappend cmdargs $name $id
7746 nowbusy newbranch
7747 update
7748 if {[catch {
7738 - exec git branch $name $id
7749 + eval exec git branch $cmdargs
7750 } err]} {
7751 notbusy newbranch
7752 error_popup $err
7753 } else {
7743 - set headids($name) $id
7744 - lappend idheads($id) $name
7745 - addedhead $id $name
7754 notbusy newbranch
7747 - redrawtags $id
7755 + if {$old_id ne {}} {
7756 + movehead $id $name
7757 + movedhead $id $name
7758 + redrawtags $old_id
7759 + redrawtags $id
7760 + } else {
7761 + set headids($name) $id
7762 + lappend idheads($id) $name
7763 + addedhead $id $name
7764 + redrawtags $id
7765 + }
7766 dispneartags 0
7767 run refill_reflist
7768 }