build: fix release name strings for gitian builds

When building from a distdir as gitian does, checking for the .git dir
is not reliable. Instead, ask git if we're in a repo.

Rebase this into 0.9.3 branch after final to make sure that 0.9.4 will
have correct version strings in rcs.

Rebased-From: c65cc8c