The problem from issue #874 has another variant:
If .git/logs/refs/heads/merge-2.067 exists then this ref is
returned as hash value(!). This is plain wrong. Solution is
again to look up `.git/packed-refs`.
After running `git gc` cmake may fail to configure the build.
`git gc` deleted the file `.git/refs/head/merge-2.067` (my current branch) and
moved the reference into file `.git/packed-refs`. This file is not parsed for
the reference.
Solution is (a) parse `.git/packed-refs` if ref is not found or (b) use
git rev-parse --symbolic-full-name HEAD
to get the reference and
git show-ref --hash ${HEAD_REF}
to get the hash.
This commits uses solution (a).
CMakeLists.txt contains now the version numbers for DMD and (next) LDC release.
If a .git folder is found then the LDC version is replaced by the first 6 chars
of the Git revision.
Possible improvements:
- If the build is not done at the master branch then it could be useful to check for a tag and use the tag instead of the revision. (for release builds)
- Maybe it is useful to include the branch name.
This fixes issue #366.