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@xxxxxxxxx> --- gitk | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gitk b/gitk index a4ef736..96ca965 100755 --- a/gitk +++ b/gitk @@ -7669,24 +7669,42 @@ proc mkbrgo {top} { set name [$top.name get] set id [$top.sha1 get] + set cmdargs [list] + set old_id {} if {$name eq {}} { error_popup [mc "Please specify a name for the new branch"] $top return } + if {[info exists headids($name)]} { + if {![confirm_popup [mc \ + "Branch '%s' already exists. Overwrite?" $name] $top]} { + 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 } -- 1.6.0.20.g6148bc -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html