Tuesday, March 17, 2015

Print the current tag OR commit in git

Here's the command to print the tag name of the current commit, or just the commit if there is no tag. It's useful for a script that builds or exports something and you always want to have some version reference..
# prints tag name or short revision
git name-rev --tags --name-only --no-undefined --always $(git rev-parse HEAD)

Monday, March 16, 2015

Multiple test programs, one makefile

I've been writing tests using glib's test framework. Some of them got quite large, so I split them up into multiple files with their own main()'s. Here's my makefile to build and test up to 10 test binaries in one go: