summaryrefslogtreecommitdiff
path: root/git-parse-remote.sh
diff options
context:
space:
mode:
authorSanti Béjar <santi@agolina.net>2009-06-11 22:39:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-06-12 02:50:34 (GMT)
commite9460a66e0d11b718757cd88eb0c927f2b79e1c8 (patch)
tree8f54583f57b9f6ce08b394478eb5f86d11120d04 /git-parse-remote.sh
parent97af7ff0553ed81bb905dbc0c8b0f9a0c10bfb3d (diff)
downloadgit-e9460a66e0d11b718757cd88eb0c927f2b79e1c8.zip
git-e9460a66e0d11b718757cd88eb0c927f2b79e1c8.tar.gz
git-e9460a66e0d11b718757cd88eb0c927f2b79e1c8.tar.bz2
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>
Diffstat (limited to 'git-parse-remote.sh')
-rwxr-xr-xgit-parse-remote.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index a991564..75e1254 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -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