2012-02-01 04:37:51 +00:00
|
|
|
#
|
|
|
|
# Displays the current Git branch.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2017-07-06 23:01:26 +00:00
|
|
|
# function git-branch-current {
|
|
|
|
|
2018-03-05 08:56:25 +00:00
|
|
|
if ! command git rev-parse 2> /dev/null; then
|
2012-09-30 19:30:18 +00:00
|
|
|
print "$0: not a repository: $PWD" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2018-03-05 08:56:25 +00:00
|
|
|
local ref="$(command git symbolic-ref HEAD 2> /dev/null)"
|
2012-09-30 19:30:18 +00:00
|
|
|
|
2011-10-12 03:13:58 +00:00
|
|
|
if [[ -n "$ref" ]]; then
|
|
|
|
print "${ref#refs/heads/}"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
2017-07-06 23:01:26 +00:00
|
|
|
|
|
|
|
# }
|