Skip to content

Commit

Permalink
parse-remote: handle detached HEAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Santi Béjar authored and Junio C Hamano committed Dec 7, 2010
1 parent 0b0cd0e commit f864f26
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git-parse-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;;
Expand Down

0 comments on commit f864f26

Please sign in to comment.