Code

git-gui: Give a better error message on an empty branch name.
authorShawn O. Pearce <spearce@spearce.org>
Sun, 21 Jan 2007 20:40:55 +0000 (15:40 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 22 Jan 2007 03:47:57 +0000 (22:47 -0500)
New branches must have a name.  An empty one is not a valid ref, but the
generic message "We do not like '' as a branch name." is just too vague
or difficult to read.  So detect the missing name early and tell the
user it must be entered.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui.sh

index c4ab824b9d860d06e0fe9239671cf2653cc4e396..0f98d2cceadfc66ce9c9f4e2558db208a7d20d6f 100755 (executable)
@@ -1696,6 +1696,16 @@ proc do_create_branch_action {w} {
        global create_branch_head create_branch_trackinghead
 
        set newbranch [string trim [$w.desc.name_t get 0.0 end]]
+       if {$newbranch eq {}} {
+               tk_messageBox \
+                       -icon error \
+                       -type ok \
+                       -title [wm title $w] \
+                       -parent $w \
+                       -message "Please supply a branch name."
+               focus $w.desc.name_t
+               return
+       }
        if {![catch {exec git show-ref --verify -- "refs/heads/$newbranch"}]} {
                tk_messageBox \
                        -icon error \