#!/bin/bash

GIT_WORK_TREE=`dirname "$0"`
## :'%h on %ci by %an: "%s"' --abbrev-commit | sed 's/\"/\\\"/g'
if [ -d "$GIT_WORK_TREE/.git" ] && v=`git log --pretty=format:'%h' --abbrev-commit -1 2>/dev/null`
then
 if dirty=`sh -c "git diff-index --name-status HEAD 2>/dev/null | sed -e 's|^\([A-Z]\).*|\1|g' | tr -d '\012'"` && [ -n "$dirty" ]
 then
   echo -n "$v|$dirty"
 else
   echo -n "$v"
 fi
# exit 0
else
 F="$1"
 if [ -r "$F" ];
 then 
   cat "$F"
 else  
   echo -n "UNKNOWN_GIT_VERSION"
 fi  
fi
