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_DIR
="$GIT_DIR" git-symbolic-ref HEAD |
16 sed -e 's|^refs/heads/||')
25 die
"Cannot delete the branch you are on." ;;
27 die
"What branch are you on anyway?" ;;
29 branch
=$
(cat "$GIT_DIR/refs/heads/$branch_name") &&
30 branch
=$
(git-rev-parse
--verify "$branch^0") ||
31 die
"Seriously, what branch are you talking about?"
36 mbs
=$
(git-merge-base
-a "$branch" HEAD |
tr '\012' ' ')
39 # the merge base of branch and HEAD contains branch --
40 # which means that the HEAD contains everything in the HEAD.
43 echo >&2 "The branch '$branch_name' is not a strict subset of your current HEAD.
44 If you are sure you want to delete it, run 'git branch -D $branch_name'."
50 rm -f "$GIT_DIR/refs/heads/$branch_name"
51 echo "Deleted branch $branch_name."
57 while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
80 git-rev-parse
--symbolic --all |
81 sed -ne 's|^refs/heads/||p' |
85 if test "$headref" = "$ref"
101 rev=$
(git-rev-parse
--verify "$head") ||
exit
103 git-check-ref-format
"heads/$branchname" ||
104 die
"we do not like '$branchname' as a branch name."
106 if [ -e "$GIT_DIR/refs/heads/$branchname" ]
108 if test '' = "$force"
110 die
"$branchname already exists."
111 elif test "$branchname" = "$headref"
113 die
"cannot force-update the current branch."
116 git update-ref
"refs/heads/$branchname" $rev