Browse Source

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>
maint
Alexander Gavrilov 17 years ago committed by Paul Mackerras
parent
commit
bee866fa6b
  1. 22
      gitk

22
gitk

@ -7727,24 +7727,42 @@ proc mkbrgo {top} {


set name [$top.name get] set name [$top.name get]
set id [$top.sha1 get] set id [$top.sha1 get]
set cmdargs {}
set old_id {}
if {$name eq {}} { if {$name eq {}} {
error_popup [mc "Please specify a name for the new branch"] error_popup [mc "Please specify a name for the new branch"]
return 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} catch {destroy $top}
lappend cmdargs $name $id
nowbusy newbranch nowbusy newbranch
update update
if {[catch { if {[catch {
exec git branch $name $id eval exec git branch $cmdargs
} err]} { } err]} {
notbusy newbranch notbusy newbranch
error_popup $err error_popup $err
} else {
notbusy newbranch
if {$old_id ne {}} {
movehead $id $name
movedhead $id $name
redrawtags $old_id
redrawtags $id
} else { } else {
set headids($name) $id set headids($name) $id
lappend idheads($id) $name lappend idheads($id) $name
addedhead $id $name addedhead $id $name
notbusy newbranch
redrawtags $id redrawtags $id
}
dispneartags 0 dispneartags 0
run refill_reflist run refill_reflist
} }

Loading…
Cancel
Save