summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79a060e)
raw | patch | inline | side by side (parent: 79a060e)
author | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 4 Jul 2007 06:19:53 +0000 (02:19 -0400) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Mon, 9 Jul 2007 01:12:50 +0000 (21:12 -0400) |
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>
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>
lib/branch_create.tcl | patch | blob | history | |
lib/choose_rev.tcl | patch | blob | history |
diff --git a/lib/branch_create.tcl b/lib/branch_create.tcl
index ef63f810f4e938a6ca33d3c2104aa32e77fa9ec8..7f82424edace4b473977d5fe9d37ee268cb3148f 100644 (file)
--- a/lib/branch_create.tcl
+++ b/lib/branch_create.tcl
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 {} {
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 \
-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
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 b3b615ee42d6e54058c5140fc3cb89d000ebcf2e..8b9241294376497abfac618d700e22dd99115f37 100644 (file)
--- a/lib/choose_rev.tcl
+++ b/lib/choose_rev.tcl
}
}
+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 }