1#!/bin/sh 2 3. git-sh-setup|| die "Not a git archive" 4 5usage () { 6echo>&2"usage:$(basename $0)"' [<branchname> [start-point]] 7 8If no arguments, show available branches and mark current branch with a star. 9If one argument, create a new branch <branchname> based off of current HEAD. 10If two arguments, create a new branch <branchname> based off of <start-point>. 11' 12exit1 13} 14 15case"$#"in 160) 17 headref=$(readlink "$GIT_DIR/HEAD" | sed -e 's|^refs/heads/||') 18 git-rev-parse --symbolic --all| 19sed-ne's|^refs/heads/||p'| 20sort| 21whileread ref 22do 23iftest"$headref"="$ref" 24then 25 pfx='*' 26else 27 pfx=' ' 28fi 29echo"$pfx$ref" 30done 31exit0;; 321) 33head=HEAD ;; 342) 35head="$2^0";; 36esac 37branchname="$1" 38 39case"$branchname"in 40-*) 41 usage;; 42esac 43 44rev=$(git-rev-parse --verify "$head")||exit 45 46[-e"$GIT_DIR/refs/heads/$branchname"] && die "$branchnamealready exists" 47 48echo$rev>"$GIT_DIR/refs/heads/$branchname"