git-gui: Option to default new branches to match tracking branches
In some workflows users will want to almost always just create a new local branch that matches a remote branch. In this type of workflow it is handy to have the new branch dialog default to "Match Tracking Branch" and "Starting Revision"-Tracking Branch", with the focus in the branch filter field. This can save users working on this type of workflow at least two mouse clicks every time they create a new local branch or switch to one with a fast-forward. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jul 5, 2007 at 01:07 UTC
7cf044266779d69d3a16322b4d505bc87267a005
4 files changed
+26
-5
git-gui.sh
+1
@@ -1339,6 +1339,7 @@ set default_config(merge.verbosity) 2
1339
set default_config(user.name) {}
1340
set default_config(user.email) {}
1341
1342
+set default_config(gui.matchtrackingbranch) false
1343
set default_config(gui.pruneduringfetch) false
1344
set default_config(gui.trustmtime) false
1345
set default_config(gui.diffcontext) 5
lib/branch_create.tcl
+20
-5
@@ -93,13 +93,14 @@ constructor dialog {} {
93
pack $w.options.checkout -anchor nw
94
pack $w.options -anchor nw -fill x -pady 5 -padx 5
95
96
+ trace add variable @name_type write [cb _select]
97
+
98
set name $repo_config(gui.newbranchtemplate)
99
+ if {[is_config_true gui.matchtrackingbranch]} {
100
+ set name_type match
101
+ }
102
98
- bind $w <Visibility> "
99
- grab $w
100
- $w_name icursor end
101
- focus $w_name
102
- "
103
+ bind $w <Visibility> [cb _visible]
104
bind $w <Key-Escape> [list destroy $w]
105
bind $w <Key-Return> [cb _create]\;break
106
tkwait window $w
@@ -361,4 +362,18 @@ method _validate {d S} {
362
return 1
363
}
364
365
+method _select {args} {
366
+ if {$name_type eq {match}} {
367
+ $w_rev pick_tracking_branch
368
+ }
369
+}
370
+
371
+method _visible {} {
372
+ grab $w
373
+ if {$name_type eq {user}} {
374
+ $w_name icursor end
375
+ focus $w_name
376
+ }
377
+}
378
+
379
}
lib/choose_rev.tcl
+4
@@ -159,6 +159,10 @@ method get {} {
159
}
160
}
161
162
+method pick_tracking_branch {} {
163
+ set revtype trck
164
+}
165
+
166
method get_tracking_branch {} {
167
set i [$w_list curselection]
168
if {$i eq {} || $revtype ne {trck}} {
lib/option.tcl
+1
@@ -191,6 +191,7 @@ proc do_options {} {
191
192
{b gui.trustmtime {Trust File Modification Timestamps}}
193
{b gui.pruneduringfetch {Prune Tracking Branches During Fetch}}
194
+ {b gui.matchtrackingbranch {Match Tracking Branches}}
195
{i-0..99 gui.diffcontext {Number of Diff Context Lines}}
196
{t gui.newbranchtemplate {New Branch Name Template}}
197
} {