chiark / gitweb /
pseudomerge: new Ingredients condition
[topbloke-formulae.git] / .git-revid
1 #!/bin/bash
2 set -e
3 set -o pipefail
4
5 kind="$1"
6
7 desc=`git describe --always HEAD`
8 log=`git log -1 --pretty='format:%h' HEAD`
9 date=`date --iso-8601=minutes`
10 set +e
11 git diff --quiet HEAD
12 diffrc=$?
13 set -e
14 case $diffrc in
15 0)      ;;
16 1)      diffplus=+ ;;
17 *)      exit $diffrc ;;
18 esac
19
20 case "$1" in
21 '')     maxlen=.71
22         ;;
23 C)      echo '#include "../.git-revid-autoversion.h"'
24         printf 'const char autoversion[]= \"'
25         log="${log//\\/\\\\}"
26         log="${log//\"/\\\"}"
27         maxlen=''
28         ;;
29 *)      echo >&2 'bad usage for .git-revid'
30         exit 1
31         ;;
32 esac
33
34 printf "%${maxlen}s" "$log $desc$diffplus $date"
35
36 case "$kind" in
37 '')     printf '\n' ;;
38 C)      echo '";' ;;
39 *)      ;;
40 esac