summaryrefslogtreecommitdiff
path: root/git-parse-remote.sh
diff options
context:
space:
mode:
authorSanti Béjar <santi@agolina.net>2010-12-06 10:20:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-12-07 00:57:48 (GMT)
commitf864f2615b76e5d74518c482ceeef3a2589017fe (patch)
tree75e63ae646daf844f2adf7c6bf8ad611b0a1e554 /git-parse-remote.sh
parent0b0cd0e0a29a139f418991dd769ea4266ffec370 (diff)
downloadgit-f864f2615b76e5d74518c482ceeef3a2589017fe.zip
git-f864f2615b76e5d74518c482ceeef3a2589017fe.tar.gz
git-f864f2615b76e5d74518c482ceeef3a2589017fe.tar.bz2
parse-remote: handle detached HEAD
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 <srabbelier@gmail.com> Signed-off-by: Santi Béjar <santi@agolina.net> Tested-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-parse-remote.sh')
-rw-r--r--git-parse-remote.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5f47b18..4da72ae 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)
;;