@matheusbsbs / matheus-bagliano / commits / 905d9c9653
Fork 0

git-gui: Allow creating a branch when none exists

If the user has no branches at all (their refs/heads/ is empty) and they are on a detached HEAD we have a valid repository but there are no branches to populate into the branch pulldown in the create branch dialog. Instead of erroring out we can skip that part of the dialog, much like we do with tracking branches or tags when the user doesn't have any. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed May 30, 2007 at 11:27 UTC 905d9c9653a7dc324a1c6fbf883a1b9bcdc6e5bf
1 file changed +8 -6
lib/branch.tcl
+8 -6
@@ -201,12 +201,14 @@ proc do_create_branch {} {
201 pack $w.desc -anchor nw -fill x -pady 5 -padx 5
202
203 labelframe $w.from -text {Starting Revision}
204 - radiobutton $w.from.head_r \
205 - -text {Local Branch:} \
206 - -value head \
207 - -variable create_branch_revtype
208 - eval tk_optionMenu $w.from.head_m create_branch_head $all_heads
209 - grid $w.from.head_r $w.from.head_m -sticky w
204 + if {$all_heads ne {}} {
205 + radiobutton $w.from.head_r \
206 + -text {Local Branch:} \
207 + -value head \
208 + -variable create_branch_revtype
209 + eval tk_optionMenu $w.from.head_m create_branch_head $all_heads
210 + grid $w.from.head_r $w.from.head_m -sticky w
211 + }
212 set all_trackings [all_tracking_branches]
213 if {$all_trackings ne {}} {
214 set create_branch_trackinghead [lindex $all_trackings 0]