summaryrefslogtreecommitdiff
path: root/git-branch-script
blob: 041ca515ae700252ca03ea928b544be6bcdeab9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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"