Created
July 29, 2014 17:58
-
-
Save lindenb/3c7f0cc391749802a120 to your computer and use it in GitHub Desktop.
including git-hash in a C program.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef GIT_HASH | |
#define GIT_HASH "f2607d7e246549d9ea54922a87001459c0235486" | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a.out: test.c githash.h | |
gcc $< | |
githash.h: | |
echo -n '#ifndef GIT_HASH\n#define GIT_HASH "' > $@ && \ | |
git rev-parse HEAD | tr -d "\n" >> $@ && \ | |
echo '"\n#endif' >> $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rm -f githash.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "githash.h" | |
int main(int argc,char** argv) | |
{ | |
return fputs("Git-Version:" GIT_HASH "\n",stdout)==0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment