I've been struggling with these two variables being nil on my build, and finally I modified emacs-repository-version-git to write a log file and see what was happening:
fatal: detected dubious ownership in repository at 'D:/Devel/emacs/repo/trunk'
'D:/Devel/emacs/repo/trunk/.git' is owned by:
'S-1-5-32-544'
but the current user is:
'S-1-5-21-...' [my account's SID]
To add an exception for this directory, call:
git config --global --add safe.directory D:/Devel/emacs/repo/trunk
One of these cases where there's a directory whose owner is the Administrators group. Changing the ownership of .git/ to the current user fixed the problem.
BTW, the git config line didn't help.
Is this usual? Should it be mentioned on some README? (Or perhaps it is already and I did miss it.)