git/V

73 lines
1.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#!/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
)
LF='
'
output=
for v in maint master next jch seen
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=
if test -z "$dirty"
then
installed=
else
installed=" $installed$dirty"
fi
elif test -z "$version"
then
in="" out=""
installed=" none"
else
installed=$(git describe --long $version)
case "$dirty" in
'')
;;
?*)
installed="$installed$dirty"
esac
in="" out="" installed=" $installed"
fi
output="$output${output:+$LF}"
output="$output$in$v$out$installed $(git describe --long refs/heads/$v)"
done
echo "$output"
echo "$output" | sha1sum | sed -e 's/ .*//'