Blame telepathy-account-widgets/tools/git-which-branch.sh

Packit 79f644
#!/bin/sh
Packit 79f644
# git-which-branch.sh - output the name of the current git branch
Packit 79f644
#
Packit 79f644
# The canonical location of this program is the telepathy-spec tools/
Packit 79f644
# directory, please synchronize any changes with that copy.
Packit 79f644
#
Packit 79f644
# Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
Packit 79f644
#
Packit 79f644
# Copying and distribution of this file, with or without modification,
Packit 79f644
# are permitted in any medium without royalty provided the copyright
Packit 79f644
# notice and this notice are preserved.
Packit 79f644
Packit 79f644
default="$1"
Packit 79f644
if { ref="`git symbolic-ref HEAD 2>/dev/null`"; }; then
Packit 79f644
    echo ${ref#refs/heads/}
Packit 79f644
    exit 0
Packit 79f644
fi
Packit 79f644
Packit 79f644
if test -n "$default"; then
Packit 79f644
    echo "$default" >/dev/null
Packit 79f644
    exit 0
Packit 79f644
fi
Packit 79f644
Packit 79f644
echo "no git branch found" >&2
Packit 79f644
exit 1