| 1 | #!/bin/sh |
| 2 | |
| 3 | inst_prefix=$( |
| 4 | IFS=: |
| 5 | for p in $PATH |
| 6 | do |
| 7 | probed=${p%/git-active/bin} |
| 8 | if test "$probed" != "$p" |
| 9 | then |
| 10 | echo "$probed" |
| 11 | exit |
| 12 | fi |
| 13 | done |
| 14 | echo $HOME |
| 15 | ) |
| 16 | |
| 17 | LF=' |
| 18 | ' |
| 19 | output= |
| 20 | for v in maint master next jch seen |
| 21 | do |
| 22 | installed=$( |
| 23 | test -f "$inst_prefix/git-$v/bin/git" && |
| 24 | "$inst_prefix/git-$v/bin/git" version |
| 25 | ) |
| 26 | dirty= |
| 27 | if version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)$') |
| 28 | then |
| 29 | : |
| 30 | elif version=$(expr "$installed" : '.*\.g\([0-9a-f]*\)\.dirty$') |
| 31 | then |
| 32 | dirty=" (with changes)" |
| 33 | elif version=v$(expr "$installed" : \ |
| 34 | 'git version \(.*\)\.rc[0-9]*$') |
| 35 | then |
| 36 | version="$version"-$(expr "$installed" : \ |
| 37 | 'git version .*\.\(rc[0-9]*\)$') |
| 38 | else |
| 39 | version=v$(expr "$installed" : 'git version \(.*\)') |
| 40 | fi |
| 41 | |
| 42 | version=$(git rev-parse --verify "$version^0" 2>/dev/null) |
| 43 | revision=$(git show-ref -s --verify "refs/heads/$v") |
| 44 | if test "z$version" = "z$revision" |
| 45 | then |
| 46 | in= out= |
| 47 | if test -z "$dirty" |
| 48 | then |
| 49 | installed= |
| 50 | else |
| 51 | installed=" $installed$dirty" |
| 52 | fi |
| 53 | elif test -z "$version" |
| 54 | then |
| 55 | in="[41;37m" out="[m" |
| 56 | installed=" none" |
| 57 | else |
| 58 | installed=$(git describe --long $version) |
| 59 | case "$dirty" in |
| 60 | '') |
| 61 | ;; |
| 62 | ?*) |
| 63 | installed="$installed$dirty" |
| 64 | esac |
| 65 | in="[41;37m" out="[m" installed=" $installed" |
| 66 | fi |
| 67 | output="$output${output:+$LF}" |
| 68 | output="$output$in$v$out$installed $(git describe --long refs/heads/$v)" |
| 69 | done |
| 70 | |
| 71 | echo "$output" |
| 72 | echo "$output" | sha1sum | sed -e 's/ .*//' |