1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-16 22:14:53 +01:00
git/git-branch-script
Junio C Hamano a38e727925 [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 <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-22 20:34:16 -07:00

17 lines
378 B
Bash
Executable file

#!/bin/sh
. git-sh-setup-script || die "Not a git archive"
branchname="$1"
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"
echo $rev > "$GIT_DIR/refs/heads/$branchname"