From 7cf044266779d69d3a16322b4d505bc87267a005 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 5 Jul 2007 01:07:06 -0400 Subject: [PATCH] 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 --- git-gui.sh | 1 + lib/branch_create.tcl | 25 ++++++++++++++++++++----- lib/choose_rev.tcl | 4 ++++ lib/option.tcl | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 63b2045d96..99df2d9480 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1339,6 +1339,7 @@ set default_config(merge.verbosity) 2 set default_config(user.name) {} set default_config(user.email) {} +set default_config(gui.matchtrackingbranch) false set default_config(gui.pruneduringfetch) false set default_config(gui.trustmtime) false set default_config(gui.diffcontext) 5 diff --git a/lib/branch_create.tcl b/lib/branch_create.tcl index 375f575eaf..df3f435e11 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 " - grab $w - $w_name icursor end - focus $w_name - " + bind $w [cb _visible] bind $w [list destroy $w] bind $w [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 + } +} + } diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index f19da0f633..e6af073595 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -159,6 +159,10 @@ method get {} { } } +method pick_tracking_branch {} { + set revtype trck +} + method get_tracking_branch {} { set i [$w_list curselection] if {$i eq {} || $revtype ne {trck}} { diff --git a/lib/option.tcl b/lib/option.tcl index ae19a8f9cf..743304269b 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -191,6 +191,7 @@ proc do_options {} { {b gui.trustmtime {Trust File Modification Timestamps}} {b gui.pruneduringfetch {Prune Tracking Branches During Fetch}} + {b gui.matchtrackingbranch {Match Tracking Branches}} {i-0..99 gui.diffcontext {Number of Diff Context Lines}} {t gui.newbranchtemplate {New Branch Name Template}} } { -- 2.11.4.GIT