3 GIT_DIR=`git-rev-parse --git-dir` || exit $?
6 echo >&2 "usage: $(basename $0)"' [-d <branch>] | [[-f] <branch> [start-point]]
8 If no arguments, show available branches and mark current branch with a star.
9 If one argument, create a new branch <branchname> based off of current HEAD.
10 If two arguments, create a new branch <branchname> based off of <start-point>.
15 headref=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
24 die "Cannot delete the branch you are on." ;;
26 die "What branch are you on anyway?" ;;
28 branch=$(cat "$GIT_DIR/refs/heads/$branch_name") &&
29 branch=$(git-rev-parse --verify "$branch^0") ||
30 die "Seriously, what branch are you talking about?"
35 mbs=$(git-merge-base -a "$branch" HEAD | tr '\012' ' ')
38 # the merge base of branch and HEAD contains branch --
39 # which means that the HEAD contains everything in the HEAD.
42 echo >&2 "The branch '$branch_name' is not a strict subset of your current HEAD.
43 If you are sure you want to delete it, run 'git branch -D $branch_name'."
49 rm -f "$GIT_DIR/refs/heads/$branch_name"
50 echo "Deleted branch $branch_name."
56 while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
79 git-rev-parse --symbolic --all |
80 sed -ne 's|^refs/heads/||p' |
84 if test "$headref" = "$ref"
100 rev=$(git-rev-parse --verify "$head") || exit
102 git-check-ref-format "heads/$branchname" ||
103 die "we do not like '$branchname' as a branch name."
105 if [ -e "$GIT_DIR/refs/heads/$branchname" ]
107 if test '' = "$force"
109 die "$branchname already exists."
110 elif test "$branchname" = "$headref"
112 die "cannot force-update the current branch."
115 git update-ref "refs/heads/$branchname" $rev