2005-07-12 06:30:23 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2005-09-08 02:26:23 +02:00
|
|
|
. git-sh-setup || die "Not a git archive"
|
2005-07-12 06:30:23 +02:00
|
|
|
|
2005-09-08 04:13:26 +02: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 19:58:10 +02: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 04:08:47 +02:00
|
|
|
head=HEAD ;;
|
2005-08-16 19:58:10 +02:00
|
|
|
2)
|
2005-07-23 04:08:47 +02:00
|
|
|
head="$2^0" ;;
|
|
|
|
esac
|
2005-08-16 19:58:10 +02:00
|
|
|
branchname="$1"
|
2005-09-08 04:13:26 +02:00
|
|
|
|
|
|
|
case "$branchname" in
|
|
|
|
-*)
|
|
|
|
usage;;
|
|
|
|
esac
|
|
|
|
|
2005-08-24 23:31:36 +02:00
|
|
|
rev=$(git-rev-parse --verify "$head") || exit
|
2005-07-12 06:30:23 +02:00
|
|
|
|
|
|
|
[ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
|
|
|
|
|
|
|
|
echo $rev > "$GIT_DIR/refs/heads/$branchname"
|