JuliaLang/julia — pull request #5629 by ivarne (2014-01-31 10:35:29+00:00)
Title: WIP: Draft for a libgit2 implementation of version_git

@StefanKarpinski indicated that he would want to use libgit2 to avoid compatibility problems with systems that use different versions of git. (see: https://github.com/JuliaLang/julia/issues/5587#issuecomment-33476326 )

This is a humble attempt to implement a simple C program to generate our `version_git.jl` file.
Missing features:
* It does not format the `GIT_VERSION_INFO.date_string` as a string but as a timestamp.
* It does not check for uncommitted changes to add a `*` to the `GIT_VERSION_INFO.commit_short` field.

Testing this is fairly easy:
```
cd ui
gcc -Wall -o version_git version_git.c -lgit2 && ./version_git
```
and it finds the repository in the current directory, just like regular git.

I hoped that this would be faster than the current shell script, but unfortunately plain git seems to be so much better to do parallel file access, that on first run on a cold machine, the shell script version is 3-4 times faster. After many runs, the libgit2 version is twice as fast, but `version_git.jl` will never be generated in a loop, so the asymptotic runtime is irrelevant.

I am posting this too see if there is interest in merging this when libgit2 becomes a dependency, and to give others that might want to try this a better starting point and a word of caution on the performance. It will add lots of dependencies for `make sourcedist`, and increase general `make` time, so I do not think it is worth to include this in the regular make process.