From a38e727925bfad369fc98165f6ff161193397f28 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Jul 2005 19:08:47 -0700 Subject: [PATCH] [PATCH] git-branch: avoid getting confused by empty or nonexisting branches. When not specifying the start point explicitly, we ended up emitting ^0 in addition to the default HEAD. Be careful to see if we have "$2" before finding out which commit to base the new branch on. Signed-off-by: Junio C Hamano Signed-off-by: Junio C Hamano --- git-branch-script | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git-branch-script b/git-branch-script index ade0abf06..041ca515a 100755 --- a/git-branch-script +++ b/git-branch-script @@ -3,7 +3,13 @@ . git-sh-setup-script || die "Not a git archive" branchname="$1" -rev=$(git-rev-parse --verify --default HEAD "$2"^0) || exit +case "$2" in +'') + head=HEAD ;; +*) + head="$2^0" ;; +esac +rev=$(git-rev-parse --revs-only --verify "$head") || exit [ -z "$branchname" ] && die "git branch: I want a branch name" [ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists" -- 2.26.2