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