summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-branch-script8
1 files changed, 7 insertions, 1 deletions
diff --git a/git-branch-script b/git-branch-script
index ade0abf..041ca51 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"