Try to check out branches upstream, debian and pristine-tar
which are known to be common branches for building git
projects.
If environment variable $branch is set check out this branch,
otherwise fall back to $GIT_COMMIT as we used to do so far.
I'm still not entirely happy with this but I'm not aware of
anything better yet...