summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-07-04 02:19:53 -0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-07-08 21:12:50 -0400
commitdd87efc8cc71ceb6aa9a27e900976c317c927846 (patch)
tree78619665e386f6d569da37a08a71e1dd09422c7f /lib
parentgit-gui: Maintain remote and source ref for tracking branches (diff)
downloadtgif-dd87efc8cc71ceb6aa9a27e900976c317c927846.tar.xz
git-gui: Allow users to match remote branch names locally
Some workflows have users create a local branch that matches a remote branch they have fetched from another repository. If the user wants to push their changes back to that remote repository then they probably want to use the same branch name locally so that git-gui's push dialog can setup the push refspec automatically. To prevent typos with the local branch name we now offer an option to use the remote tracking branch name as the new local branch name. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/branch_create.tcl45
-rw-r--r--lib/choose_rev.tcl8
2 files changed, 49 insertions, 4 deletions
diff --git a/lib/branch_create.tcl b/lib/branch_create.tcl
index ef63f810f4..7f82424eda 100644
--- a/lib/branch_create.tcl
+++ b/lib/branch_create.tcl
@@ -8,6 +8,8 @@ field w_rev ; # mega-widget to pick the initial revision
field w_name ; # new branch name widget
field name {}; # name of the branch the user has chosen
+field name_type user; # type of branch name to use
+
field opt_checkout 1; # automatically checkout the new branch?
constructor dialog {} {
@@ -32,10 +34,12 @@ constructor dialog {} {
pack $w.buttons.cancel -side right -padx 5
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
- labelframe $w.desc -text {Branch Description}
- label $w.desc.name_r \
+ labelframe $w.desc -text {Branch Name}
+ radiobutton $w.desc.name_r \
-anchor w \
- -text {Name:}
+ -text {Name:} \
+ -value user \
+ -variable @name_type
set w_name $w.desc.name_t
entry $w_name \
-borderwidth 1 \
@@ -46,6 +50,13 @@ constructor dialog {} {
-validatecommand [cb _validate %d %S]
grid $w.desc.name_r $w_name -sticky we -padx {0 5}
+ radiobutton $w.desc.match_r \
+ -anchor w \
+ -text {Match Tracking Branch Name} \
+ -value match \
+ -variable @name_type
+ grid $w.desc.match_r -sticky we -padx {0 5} -columnspan 2
+
grid columnconfigure $w.desc 1 -weight 1
pack $w.desc -anchor nw -fill x -pady 5 -padx 5
@@ -75,7 +86,33 @@ method _create {} {
global null_sha1 repo_config
global all_heads
- set newbranch $name
+ switch -- $name_type {
+ user {
+ set newbranch $name
+ }
+ match {
+ set spec [$w_rev get_tracking_branch]
+ if {$spec eq {}} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Please select a tracking branch."
+ return
+ }
+ if {![regsub ^refs/heads/ [lindex $spec 2] {} newbranch]} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Tracking branch [$w get] is not a branch in the remote repository."
+ return
+ }
+ }
+ }
+
if {$newbranch eq {}
|| $newbranch eq $repo_config(gui.newbranchtemplate)} {
tk_messageBox \
diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl
index b3b615ee42..8b92412943 100644
--- a/lib/choose_rev.tcl
+++ b/lib/choose_rev.tcl
@@ -128,6 +128,14 @@ method get {} {
}
}
+method get_tracking_branch {} {
+ if {$revtype eq {trck}} {
+ return $trck_spec($c_trck)
+ } else {
+ return {}
+ }
+}
+
method get_expr {} {
switch -- $revtype {
head { return refs/heads/$c_head }