Git commit hash is not written to file by write_version_githash()

The git commit id is always UNKNOWN although get_git_commit_hash() gives the correct results.