2005-07-12 08:30:23 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2005-09-08 04:26:23 +04:00
|
|
|
. git-sh-setup || die "Not a git archive"
|
2005-07-12 08:30:23 +04:00
|
|
|
|
2005-09-08 06:13:26 +04:00
|
|
|
usage () {
|
|
|
|
echo >&2 "usage: $(basename $0)"' [<branchname> [start-point]]
|
|
|
|
|
|
|
|
If no arguments, show available branches and mark current branch with a star.
|
|
|
|
If one argument, create a new branch <branchname> based off of current HEAD.
|
|
|
|
If two arguments, create a new branch <branchname> based off of <start-point>.
|
|
|
|
'
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2005-08-16 21:58:10 +04:00
|
|
|
case "$#" in
|
|
|
|
0)
|
|
|
|
headref=$(readlink "$GIT_DIR/HEAD" | sed -e 's|^refs/heads/||')
|
|
|
|
git-rev-parse --symbolic --all |
|
|
|
|
sed -ne 's|^refs/heads/||p' |
|
|
|
|
sort |
|
|
|
|
while read ref
|
|
|
|
do
|
|
|
|
if test "$headref" = "$ref"
|
|
|
|
then
|
|
|
|
pfx='*'
|
|
|
|
else
|
|
|
|
pfx=' '
|
|
|
|
fi
|
|
|
|
echo "$pfx $ref"
|
|
|
|
done
|
|
|
|
exit 0 ;;
|
|
|
|
1)
|
2005-07-23 06:08:47 +04:00
|
|
|
head=HEAD ;;
|
2005-08-16 21:58:10 +04:00
|
|
|
2)
|
2005-07-23 06:08:47 +04:00
|
|
|
head="$2^0" ;;
|
|
|
|
esac
|
2005-08-16 21:58:10 +04:00
|
|
|
branchname="$1"
|
2005-09-08 06:13:26 +04:00
|
|
|
|
|
|
|
case "$branchname" in
|
|
|
|
-*)
|
|
|
|
usage;;
|
|
|
|
esac
|
|
|
|
|
2005-08-25 01:31:36 +04:00
|
|
|
rev=$(git-rev-parse --verify "$head") || exit
|
2005-07-12 08:30:23 +04:00
|
|
|
|
|
|
|
[ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
|
|
|
|
|
|
|
|
echo $rev > "$GIT_DIR/refs/heads/$branchname"
|