]> git.0d.be Git - empathy.git/blob - tools/git-which-branch.sh
3.12.6
[empathy.git] / tools / git-which-branch.sh
1 #!/bin/sh
2 # git-which-branch.sh - output the name of the current git branch
3 #
4 # The canonical location of this program is the telepathy-spec tools/
5 # directory, please synchronize any changes with that copy.
6 #
7 # Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
8 #
9 # Copying and distribution of this file, with or without modification,
10 # are permitted in any medium without royalty provided the copyright
11 # notice and this notice are preserved.
12
13 default="$1"
14 if { ref="`git symbolic-ref HEAD 2>/dev/null`"; }; then
15     echo ${ref#refs/heads/}
16     exit 0
17 fi
18
19 if test -n "$default"; then
20     echo "$default" >/dev/null
21     exit 0
22 fi
23
24 echo "no git branch found" >&2
25 exit 1