]> git.ipfire.org Git - thirdparty/git.git/blame - git-branch.sh
[PATCH] remove duplicate git-send-email-script.perl target in Makefile
[thirdparty/git.git] / git-branch.sh
CommitLineData
37f1a519
LT
1#!/bin/sh
2
215a7ad1 3. git-sh-setup || die "Not a git archive"
37f1a519 4
a3b427b9
AW
5usage () {
6 echo >&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'
12 exit 1
13}
14
e4aec26f
KV
15case "$#" in
160)
17 headref=$(readlink "$GIT_DIR/HEAD" | sed -e 's|^refs/heads/||')
18 git-rev-parse --symbolic --all |
19 sed -ne 's|^refs/heads/||p' |
20 sort |
21 while read ref
22 do
23 if test "$headref" = "$ref"
24 then
25 pfx='*'
26 else
27 pfx=' '
28 fi
29 echo "$pfx $ref"
30 done
31 exit 0 ;;
321)
a38e7279 33 head=HEAD ;;
e4aec26f 342)
a38e7279
JH
35 head="$2^0" ;;
36esac
e4aec26f 37branchname="$1"
a3b427b9
AW
38
39case "$branchname" in
40-*)
41 usage;;
42esac
43
ff84d327 44rev=$(git-rev-parse --verify "$head") || exit
37f1a519 45
37f1a519
LT
46[ -e "$GIT_DIR/refs/heads/$branchname" ] && die "$branchname already exists"
47
48echo $rev > "$GIT_DIR/refs/heads/$branchname"