Find appropriate upstream branch in case current isn't remote.

https://bugs.tddium.com/bugzilla/show_bug.cgi?id=522