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