From 239fb4df99e7226890b190aaef0a20d60c8f420a Mon Sep 17 00:00:00 2001 From: Tom Maenan Read Cutting Date: Mon, 16 Oct 2017 20:40:56 +0100 Subject: [PATCH] Make sure `git open issue` uses `upstream` only if exists --- git-open | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-open b/git-open index ac6bad0..9978261 100755 --- a/git-open +++ b/git-open @@ -26,6 +26,11 @@ fi # assume remote origin if not provided (unless we are opening an issue, then use upstream) if (( is_issue )); then remote=${1:-"upstream"} + giturl=$(git config --get "remote.${remote}.url") + # @TODO ls-remote will also expand "insteadOf" items `giturl=$(git ls-remote --get-url $remote)` + if [[ -z "$giturl" ]]; then + remote=${1:-"origin"} + fi else remote=${1:-"origin"} fi