@matheusbsbs / matheus-bagliano / commits / f864f2615b
Fork 0

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>

Santi Béjar committed Dec 6, 2010 at 11:20 UTC f864f2615b76e5d74518c482ceeef3a2589017fe
1 file changed +1 -1
git-parse-remote.sh
+1 -1
@@ -66,7 +66,7 @@ get_remote_merge_branch () {
66 origin="$1"
67 default=$(get_default_remote)
68 test -z "$origin" && origin=$default
69 - curr_branch=$(git symbolic-ref -q HEAD)
69 + curr_branch=$(git symbolic-ref -q HEAD) &&
70 [ "$origin" = "$default" ] &&
71 echo $(git for-each-ref --format='%(upstream)' $curr_branch)
72 ;;