git/V
2009-04-26 19:48:39 -07:00

61 lines
1.2 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
inst_prefix=$(
IFS=:
for p in $PATH
do
probed=${p%/git-active/bin}
if test "$probed" != "$p"
then
echo "$probed"
exit
fi
done
echo $HOME
)
for v in maint master next pu jch
do
installed=$(
test -f "$inst_prefix/git-$v/bin/git" &&
"$inst_prefix/git-$v/bin/git" version
)
dirty=
if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$')
then
:
elif version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)\.dirty$')
then
dirty=" (with changes)"
elif version=v$(expr "$installed" : \
'git version \(.*\)\.rc[0-9]*$')
then
version="$version"-$(expr "$installed" : \
'git version .*\.\(rc[0-9]*\)$')
else
version=v$(expr "$installed" : 'git version \(.*\)')
fi
version=$(git rev-parse --verify "$version^0" 2>/dev/null)
revision=$(git show-ref -s --verify "refs/heads/$v")
if test "z$version" = "z$revision"
then
in= out=
installed=$dirty
elif test -z "$version"
then
in="" out=""
installed=" none"
else
installed=$(git describe $version)
case "$dirty" in
'')
;;
?*)
installed="$installed$dirty"
esac
in="" out="" installed=" $installed"
fi
echo "$in$v$out $(git describe refs/heads/$v)$installed"
done