From f864f2615b76e5d74518c482ceeef3a2589017fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Santi=20B=C3=A9jar?= Date: Mon, 6 Dec 2010 11:20:11 +0100 Subject: [PATCH] parse-remote: handle detached HEAD MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit get_remote_merge_branch with zero or one arguments returns the upstream branch. But a detached HEAD does no have an upstream branch, as it is not tracking anything. Handle this case testing the exit code of "git symbolic-ref -q HEAD". Reported-by: Sverre Rabbelier Signed-off-by: Santi Béjar Tested-by: Sverre Rabbelier Signed-off-by: Junio C Hamano --- git-parse-remote.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 5f47b1814..4da72aefb 100644 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -66,7 +66,7 @@ get_remote_merge_branch () { origin="$1" default=$(get_default_remote) test -z "$origin" && origin=$default - curr_branch=$(git symbolic-ref -q HEAD) + curr_branch=$(git symbolic-ref -q HEAD) && [ "$origin" = "$default" ] && echo $(git for-each-ref --format='%(upstream)' $curr_branch) ;; -- 2.30.2