Change win32 git branch extraction to use same approach as generate-version.sh

Sorry for just adding a change to my previous pull request a few minutes later but I think this is better now since it uses the exactly the same approach as the shell script.