mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
3eae308700
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCAAGBQJYCJqmAAoJEDn3Aot9nM55uKQP/11BTzhOr9K3SLzwCr01ylGP 94AOA511vx3fIX5aWQ29S96tGbluo73RdbVsWFKKJcKSErpFPscFEiRkyjeMXE2T yWWOPOg08tm28ppZNp0Kqjb8VykUUKuG6gVT59DNFUZUqHYQbiQy+t8nwT+Qow3U dvo6lksovfSaW2FORWIi5KF5gD4v2F9qsbFgr725a8UoBrOmF0SWaCG4/ZYj0WxF 0rq8LjpvmMuQqd06DAoGMIsHa71R61En2QWfJ4YoE5+QRq8wQl37FmX+ojiA1rzY CG/vJO2Tw4v54wHKK1TCXG7LR4JhTcQZOa6zd8HHsPRn+viGDCMVUG9uMewfxH+m F47EVMxiKf0subm3fUhycqkvso0r6mOAddhz47RKT7tqU4XOnhPyGw0x6m7evawg Sz2+fOK3wwX2Qec5o3vBZKaEcOftSrLuZmbi5/j43crvcf+OAs9s/jdq/Ulpkks2 JI2i0DLzHABTbDn6QsuysEZnituks8T8Fdm5NOldritgBNVY81ifatekFscxt6Ct OrT9eGJk6iZiX1RvS+R7wykKJCBkxiyHqM8vSj5tPWjApgtnopPMudzNX41geaL9 ADeb8LVMTTNL/md8KED0deypilcPNnPbW035rAbyCpAsKbtgO3zdfzdzxsQ+dIvc MQpCDP5QPPr3toRVdNmb =VyhL -----END PGP SIGNATURE----- Merge tag 'gitgui-0.21.0' of git://repo.or.cz/git-gui git-gui 0.21.0 * tag 'gitgui-0.21.0' of git://repo.or.cz/git-gui: (22 commits) git-gui: set version 0.21 git-gui: Mark 'All' in remote.tcl for translation git-gui i18n: Updated Bulgarian translation (565,0f,0u) git-gui: avoid persisting modified author identity git-gui: handle the encoding of Git's output correctly git-gui: unicode file name support on windows git-gui: Update Russian translation git-gui: maintain backwards compatibility for merge syntax git-gui i18n: mark string in lib/error.tcl for translation git-gui: fix incorrect use of Tcl append command git-gui i18n: mark "usage:" strings for translation git-gui i18n: internationalize use of colon punctuation git-gui: ensure the file in the diff pane is in the list of selected files git-gui: support for $FILENAMES in tool definitions git-gui: fix initial git gui message encoding git-gui/po/glossary/txt-to-pot.sh: use the $( ... ) construct for command substitution git-gui (Windows): use git-gui.exe in `Create Desktop Shortcut` git-gui: fix detection of Cygwin Amend tab ordering and text widget border and highlighting. Allow keyboard control to work in the staging widgets. ...
134 lines
3.1 KiB
Tcl
134 lines
3.1 KiB
Tcl
# git-gui branch rename support
|
|
# Copyright (C) 2007 Shawn Pearce
|
|
|
|
class branch_rename {
|
|
|
|
field w
|
|
field oldname
|
|
field newname
|
|
|
|
constructor dialog {} {
|
|
global current_branch use_ttk NS
|
|
|
|
make_dialog top w
|
|
wm withdraw $w
|
|
wm title $top [mc "%s (%s): Rename Branch" [appname] [reponame]]
|
|
if {$top ne {.}} {
|
|
wm geometry $top "+[winfo rootx .]+[winfo rooty .]"
|
|
}
|
|
|
|
set oldname $current_branch
|
|
set newname [get_config gui.newbranchtemplate]
|
|
|
|
${NS}::label $w.header -text [mc "Rename Branch"]\
|
|
-font font_uibold -anchor center
|
|
pack $w.header -side top -fill x
|
|
|
|
${NS}::frame $w.buttons
|
|
${NS}::button $w.buttons.rename -text [mc Rename] \
|
|
-default active \
|
|
-command [cb _rename]
|
|
pack $w.buttons.rename -side right
|
|
${NS}::button $w.buttons.cancel -text [mc Cancel] \
|
|
-command [list destroy $w]
|
|
pack $w.buttons.cancel -side right -padx 5
|
|
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
|
|
|
|
${NS}::frame $w.rename
|
|
${NS}::label $w.rename.oldname_l -text [mc "Branch:"]
|
|
if {$use_ttk} {
|
|
ttk::combobox $w.rename.oldname_m -textvariable @oldname \
|
|
-values [load_all_heads] -state readonly
|
|
} else {
|
|
eval tk_optionMenu $w.rename.oldname_m @oldname [load_all_heads]
|
|
}
|
|
|
|
${NS}::label $w.rename.newname_l -text [mc "New Name:"]
|
|
${NS}::entry $w.rename.newname_t \
|
|
-width 40 \
|
|
-textvariable @newname \
|
|
-validate key \
|
|
-validatecommand {
|
|
if {%d == 1 && [regexp {[~^:?*\[\0- ]} %S]} {return 0}
|
|
return 1
|
|
}
|
|
|
|
grid $w.rename.oldname_l $w.rename.oldname_m -sticky we -padx {0 5}
|
|
grid $w.rename.newname_l $w.rename.newname_t -sticky we -padx {0 5}
|
|
grid columnconfigure $w.rename 1 -weight 1
|
|
pack $w.rename -anchor nw -fill x -pady 5 -padx 5
|
|
|
|
bind $w <Key-Return> [cb _rename]
|
|
bind $w <Key-Escape> [list destroy $w]
|
|
bind $w <Visibility> "
|
|
grab $w
|
|
$w.rename.newname_t icursor end
|
|
focus $w.rename.newname_t
|
|
"
|
|
wm deiconify $w
|
|
tkwait window $w
|
|
}
|
|
|
|
method _rename {} {
|
|
global current_branch
|
|
|
|
if {$oldname eq {}} {
|
|
tk_messageBox \
|
|
-icon error \
|
|
-type ok \
|
|
-title [wm title $w] \
|
|
-parent $w \
|
|
-message [mc "Please select a branch to rename."]
|
|
focus $w.rename.oldname_m
|
|
return
|
|
}
|
|
if {$newname eq {}
|
|
|| $newname eq [get_config gui.newbranchtemplate]} {
|
|
tk_messageBox \
|
|
-icon error \
|
|
-type ok \
|
|
-title [wm title $w] \
|
|
-parent $w \
|
|
-message [mc "Please supply a branch name."]
|
|
focus $w.rename.newname_t
|
|
return
|
|
}
|
|
if {![catch {git show-ref --verify -- "refs/heads/$newname"}]} {
|
|
tk_messageBox \
|
|
-icon error \
|
|
-type ok \
|
|
-title [wm title $w] \
|
|
-parent $w \
|
|
-message [mc "Branch '%s' already exists." $newname]
|
|
focus $w.rename.newname_t
|
|
return
|
|
}
|
|
if {[catch {git check-ref-format "heads/$newname"}]} {
|
|
tk_messageBox \
|
|
-icon error \
|
|
-type ok \
|
|
-title [wm title $w] \
|
|
-parent $w \
|
|
-message [mc "'%s' is not an acceptable branch name." $newname]
|
|
focus $w.rename.newname_t
|
|
return
|
|
}
|
|
|
|
if {[catch {git branch -m $oldname $newname} err]} {
|
|
tk_messageBox \
|
|
-icon error \
|
|
-type ok \
|
|
-title [wm title $w] \
|
|
-parent $w \
|
|
-message [strcat [mc "Failed to rename '%s'." $oldname] "\n\n$err"]
|
|
return
|
|
}
|
|
|
|
if {$current_branch eq $oldname} {
|
|
set current_branch $newname
|
|
}
|
|
|
|
destroy $w
|
|
}
|
|
|
|
}
|