3 . git-sh-setup || die
"Not a git archive"
6 echo >&2 "usage: $(basename $0)"' [-d <branch>] | [<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>.
16 option
="$1" branch_name
="$2"
17 headref
=$
(GIT_DIR
="$GIT_DIR" git-symbolic-ref HEAD |
18 sed -e 's|^refs/heads/||')
21 die
"Cannot delete the branch you are on." ;;
23 die
"What branch are you on anyway?" ;;
25 branch
=$
(cat "$GIT_DIR/refs/heads/$branch_name") &&
26 branch
=$
(git-rev-parse
--verify "$branch^0") ||
27 die
"Seriously, what branch are you talking about?"
32 mbs
=$
(git-merge-base
-a "$branch" HEAD |
tr '\012' ' ')
35 # the merge base of branch and HEAD contains branch --
36 # which means that the HEAD contains everything in the HEAD.
39 echo >&2 "The branch '$branch_name' is not a strict subset of your current HEAD.
40 If you are sure you want to delete it, run 'git branch -D $branch_name'."
46 rm -f "$GIT_DIR/refs/heads/$branch_name"
47 echo "Deleted branch $branch_name."
51 while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
55 delete_branch
"$1" "$2"
71 headref
=$
(GIT_DIR
="$GIT_DIR" git-symbolic-ref HEAD |
72 sed -e 's|^refs/heads/||')
73 git-rev-parse
--symbolic --all |
74 sed -ne 's|^refs/heads/||p' |
78 if test "$headref" = "$ref"
94 rev=$
(git-rev-parse
--verify "$head") ||
exit
96 [ -e "$GIT_DIR/refs/heads/$branchname" ] && die
"$branchname already exists"
98 echo $rev > "$GIT_DIR/refs/heads/$branchname"