summaryrefslogtreecommitdiff
path: root/lib/branch_create.tcl
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-07-05 05:07:06 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-07-09 01:12:54 (GMT)
commit7cf044266779d69d3a16322b4d505bc87267a005 (patch)
tree433e6ed16c8689c5d7b7b884b96d1bb255a48085 /lib/branch_create.tcl
parent560eddc00c02e82077998200e8d8a45c31af924c (diff)
downloadgit-7cf044266779d69d3a16322b4d505bc87267a005.zip
git-7cf044266779d69d3a16322b4d505bc87267a005.tar.gz
git-7cf044266779d69d3a16322b4d505bc87267a005.tar.bz2
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>
Diffstat (limited to 'lib/branch_create.tcl')
-rw-r--r--lib/branch_create.tcl25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/branch_create.tcl b/lib/branch_create.tcl
index 375f575..df3f435 100644
--- a/lib/branch_create.tcl
+++ b/lib/branch_create.tcl
@@ -93,13 +93,14 @@ constructor dialog {} {
pack $w.options.checkout -anchor nw
pack $w.options -anchor nw -fill x -pady 5 -padx 5
+ trace add variable @name_type write [cb _select]
+
set name $repo_config(gui.newbranchtemplate)
+ if {[is_config_true gui.matchtrackingbranch]} {
+ set name_type match
+ }
- bind $w <Visibility> "
- grab $w
- $w_name icursor end
- focus $w_name
- "
+ bind $w <Visibility> [cb _visible]
bind $w <Key-Escape> [list destroy $w]
bind $w <Key-Return> [cb _create]\;break
tkwait window $w
@@ -361,4 +362,18 @@ method _validate {d S} {
return 1
}
+method _select {args} {
+ if {$name_type eq {match}} {
+ $w_rev pick_tracking_branch
+ }
+}
+
+method _visible {} {
+ grab $w
+ if {$name_type eq {user}} {
+ $w_name icursor end
+ focus $w_name
+ }
+}
+
}