Autotools: Fix checking for Git revision

Fix check when building out of tree, and properly handle errors.