Also adds ability to disable check with BITCOIN_GENBUILD_NO_GIT=1 in the environment @theuni @Flowdalic @laanwj
I believe this addresses all the possible use cases correctly.
(This commit is based on branch-0.10, so should merge cleanly into 0.10, 0.11, 0.12, and master branches.)