create-git-version-h.sh 313 Bytes
Newer Older
1 2
#!/bin/sh

3 4 5
GITV_H=git-version.h
GITV_H_TMP=git-version.h.tmp

6 7
touch ${GITV_H}

8 9 10 11
git log -1 --pretty=format:'#define GIT_VERSION "%h (%cd)"' --date=short --abbrev-commit > ${GITV_H_TMP} 2> /dev/null

# Replace the file only when the new file is different
diff ${GITV_H} ${GITV_H_TMP} || mv ${GITV_H_TMP} ${GITV_H}
12