parse-remote: support default reflist in get_remote_merge_branch

Expand get_remote_merge_branch to compute the tracking branch to merge
when called without arguments (or only the remote name). This allows
"git pull --rebase" without arguments (default upstream branch) to
work with a rebased upstream. With explicit arguments it already worked.

Also add a test to check for this case.

Signed-off-by: Santi Béjar <santi@agolina.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Santi Béjar
2009-06-12 00:39:19 +02:00
committed by Junio C Hamano
parent 97af7ff055
commit e9460a66e0
2 changed files with 21 additions and 1 deletions

View File

@ -232,7 +232,13 @@ get_remote_refs_for_fetch () {
get_remote_merge_branch () {
case "$#" in
0|1)
die "internal error: get-remote-merge-branch." ;;
origin="$1"
default=$(get_default_remote)
test -z "$origin" && origin=$default
curr_branch=$(git symbolic-ref -q HEAD)
[ "$origin" = "$default" ] &&
echo $(git for-each-ref --format='%(upstream)' $curr_branch)
;;
*)
repo=$1
shift