Move _git_upstream_state function into git-sh script