提交 a38e7279 编写于 作者: J Junio C Hamano 提交者: Linus Torvalds

[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: NJunio C Hamano <junkio@cox.net>
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 5bb2c65a
......@@ -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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册