ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
 
# Check for git and a git repo.
git_version() {
   if head=`git rev-parse --verify HEAD 2>/dev/null`; then
       # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
       # it, because this version is defined in the top level Makefile.
       if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
 
           # If we are past a tagged commit (like
           # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
           if atag="`git describe 2>/dev/null`"; then
               echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
 
           # If we don't have a tag at all we print -g{commitish}.
           else
           printf '%s' $head
           fi
 
           # Check for uncommitted changes
           if git diff-index --name-only HEAD | grep -qv "^scripts/"; then
               printf '%s' -dirty
           fi
       fi
 
   fi
   # All done with git
   return
}
 
git_version;