aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2008-10-08 11:05:35 +0400
committerPaul Mackerras <paulus@samba.org>2008-10-21 22:37:36 +1100
commitbee866fa6b5a77f65d9915f8778919ef76d9d6c1 (patch)
tree837b44ed513aedf68d0896f318e1b380b1886fa6
parentd375ef9b1483c3c828d78ce08adae6aae8e19f75 (diff)
downloadgit-bee866fa6b5a77f65d9915f8778919ef76d9d6c1.tar.gz
git-bee866fa6b5a77f65d9915f8778919ef76d9d6c1.tar.xz
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>
-rwxr-xr-xgitk28
1 files changed, 23 insertions, 5 deletions
diff --git a/gitk b/gitk
index bcebc87f7..5830941b7 100755
--- a/gitk
+++ b/gitk
@@ -7727,24 +7727,42 @@ proc mkbrgo {top} {
set name [$top.name get]
set id [$top.sha1 get]
+ set cmdargs {}
+ set old_id {}
if {$name eq {}} {
error_popup [mc "Please specify a name for the new branch"]
return
}
+ if {[info exists headids($name)]} {
+ if {![confirm_popup [mc \
+ "Branch '%s' already exists. Overwrite?" $name]]} {
+ return
+ }
+ set old_id $headids($name)
+ lappend cmdargs -f
+ }
catch {destroy $top}
+ lappend cmdargs $name $id
nowbusy newbranch
update
if {[catch {
- exec git branch $name $id
+ eval exec git branch $cmdargs
} err]} {
notbusy newbranch
error_popup $err
} else {
- set headids($name) $id
- lappend idheads($id) $name
- addedhead $id $name
notbusy newbranch
- redrawtags $id
+ if {$old_id ne {}} {
+ movehead $id $name
+ movedhead $id $name
+ redrawtags $old_id
+ redrawtags $id
+ } else {
+ set headids($name) $id
+ lappend idheads($id) $name
+ addedhead $id $name
+ redrawtags $id
+ }
dispneartags 0
run refill_reflist
}