git-gui: Allow user to specify a branch name pattern.
Typically I'm creating all new branches with the same prefix, e.g. 'sp/'. So its handy to be able to setup a repository (or global) level config option for git gui which contains this initial prefix. Once set then git-gui will load it into the new branch name field whenever a new branch is being created. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 21, 2007 at 16:28 UTC
c845692d7551cbcbfd8c6dda2aa2e3b135838e39
1 file changed
+34
-5
git-gui.sh
+34
-5
@@ -1691,12 +1691,13 @@ proc all_tracking_branches {} {
1691
}
1692
1693
proc do_create_branch_action {w} {
1694
- global all_heads null_sha1
1694
+ global all_heads null_sha1 repo_config
1695
global create_branch_checkout create_branch_revtype
1696
global create_branch_head create_branch_trackinghead
1697
1698
set newbranch [string trim [$w.desc.name_t get 0.0 end]]
1699
- if {$newbranch eq {}} {
1699
+ if {$newbranch eq {}
1700
+ || $newbranch eq $repo_config(gui.newbranchtemplate)} {
1701
tk_messageBox \
1702
-icon error \
1703
-type ok \
@@ -1768,7 +1769,7 @@ proc do_create_branch_action {w} {
1769
}
1770
1771
proc do_create_branch {} {
1771
- global all_heads current_branch
1772
+ global all_heads current_branch repo_config
1773
global create_branch_checkout create_branch_revtype
1774
global create_branch_head create_branch_trackinghead
1775
@@ -1807,6 +1808,7 @@ proc do_create_branch {} {
1808
-height 1 \
1809
-width 40 \
1810
-font font_ui
1811
+ $w.desc.name_t insert 0.0 $repo_config(gui.newbranchtemplate)
1812
grid $w.desc.name_l $w.desc.name_t -stick we -padx {0 5}
1813
bind $w.desc.name_t <Shift-Key-Tab> "focus $w.postActions.checkout;break"
1814
bind $w.desc.name_t <Key-Tab> "focus $w.from.exp_t;break"
@@ -2986,7 +2988,10 @@ proc do_options {} {
2988
pack $w.buttons.restore -side left
2989
button $w.buttons.save -text Save \
2990
-font font_ui \
2989
- -command [list do_save_config $w]
2991
+ -command "
2992
+ catch {eval \[bind \[focus -displayof $w\] <FocusOut>\]}
2993
+ do_save_config $w
2994
+ "
2995
pack $w.buttons.save -side right
2996
button $w.buttons.cancel -text {Cancel} \
2997
-font font_ui \
@@ -3007,6 +3012,7 @@ proc do_options {} {
3012
{b pullsummary {Show Pull Summary}}
3013
{b trustmtime {Trust File Modification Timestamps}}
3014
{i diffcontext {Number of Diff Context Lines}}
3015
+ {t newbranchtemplate {New Branch Name Template}}
3016
} {
3017
set type [lindex $option 0]
3018
set name [lindex $option 1]
@@ -3030,7 +3036,29 @@ proc do_options {} {
3036
-from 1 -to 99 -increment 1 \
3037
-width 3 \
3038
-font font_ui
3033
- pack $w.$f.$name.v -side right -anchor e
3039
+ pack $w.$f.$name.v -side right -anchor e -padx 5
3040
+ pack $w.$f.$name -side top -anchor w -fill x
3041
+ }
3042
+ t {
3043
+ frame $w.$f.$name
3044
+ label $w.$f.$name.l -text "$text:" -font font_ui
3045
+ text $w.$f.$name.v \
3046
+ -borderwidth 1 \
3047
+ -relief sunken \
3048
+ -height 1 \
3049
+ -width 20 \
3050
+ -font font_ui
3051
+ $w.$f.$name.v insert 0.0 [set ${f}_config_new(gui.$name)]
3052
+ bind $w.$f.$name.v <Key-Tab> break
3053
+ bind $w.$f.$name.v <Key-Return> break
3054
+ bind $w.$f.$name.v <FocusOut> "
3055
+ set ${f}_config_new(gui.$name) \
3056
+ \[string trim \[$w.$f.$name.v get 0.0 end\]\]
3057
+ "
3058
+ pack $w.$f.$name.l -side left -anchor w
3059
+ pack $w.$f.$name.v -side left -anchor w \
3060
+ -fill x -expand 1 \
3061
+ -padx 5
3062
pack $w.$f.$name -side top -anchor w -fill x
3063
}
3064
}
@@ -3364,6 +3392,7 @@ proc apply_config {} {
3392
set default_config(gui.trustmtime) false
3393
set default_config(gui.pullsummary) true
3394
set default_config(gui.diffcontext) 5
3395
+set default_config(gui.newbranchtemplate) {}
3396
set default_config(gui.fontui) [font configure font_ui]
3397
set default_config(gui.fontdiff) [font configure font_diff]
3398
set font_descs {