setlocalversion 527 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. # Print additional version information for non-release trees.
  3. usage() {
  4. echo "Usage: $0 [srctree]" >&2
  5. exit 1
  6. }
  7. cd "${1:-.}" || usage
  8. # Check for git and a git repo.
  9. if head=`git rev-parse --verify HEAD 2>/dev/null`; then
  10. # Do we have an untagged version?
  11. if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
  12. printf '%s%s' -g `echo "$head" | cut -c1-8`
  13. fi
  14. # Are there uncommitted changes?
  15. if git diff-index HEAD | read dummy; then
  16. printf '%s' -dirty
  17. fi
  18. fi