3 USAGE='[-l] [(-d | -D) <branchname>] | [[-f] <branchname> [<start-point>]] | -r'
4 LONG_USAGE='If no arguments, show available branches and mark current branch with a star.
5 If one argument, create a new branch <branchname> based off of current HEAD.
6 If two arguments, create a new branch <branchname> based off of <start-point>.'
11 headref=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
20 die "Cannot delete the branch you are on." ;;
22 die "What branch are you on anyway?" ;;
24 branch=$(cat "$GIT_DIR/refs/heads/$branch_name") &&
25 branch=$(git-rev-parse --verify "$branch^0") ||
26 die "Seriously, what branch are you talking about?"
31 mbs=$(git-merge-base -a "$branch" HEAD | tr '\012' ' ')
34 # the merge base of branch and HEAD contains branch --
35 # which means that the HEAD contains everything in both.
38 echo >&2 "The branch '$branch_name' is not a strict subset of your current HEAD.
39 If you are sure you want to delete it, run 'git branch -D $branch_name'."
45 rm -f "$GIT_DIR/logs/refs/heads/$branch_name"
46 rm -f "$GIT_DIR/refs/heads/$branch_name"
47 echo "Deleted branch $branch_name."
52 ls_remote_branches () {
53 git-rev-parse --symbolic --all |
54 sed -ne 's|^refs/\(remotes/\)|\1|p' |
60 while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
90 git-rev-parse --symbolic --branches |
94 if test "$headref" = "$ref"
110 rev=$(git-rev-parse --verify "$head") || exit
112 git-check-ref-format "heads/$branchname" ||
113 die "we do not like '$branchname' as a branch name."
115 if [ -e "$GIT_DIR/refs/heads/$branchname" ]
117 if test '' = "$force"
119 die "$branchname already exists."
120 elif test "$branchname" = "$headref"
122 die "cannot force-update the current branch."
125 if test "$create_log" = 'yes'
127 mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$branchname")
128 touch "$GIT_DIR/logs/refs/heads/$branchname"
130 git update-ref -m "branch: Created from $head" "refs/heads/$branchname" $rev