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

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>

Santi Béjar committed Jun 12, 2009 at 00:39 UTC e9460a66e0d11b718757cd88eb0c927f2b79e1c8
2 files changed +21 -1
git-parse-remote.sh
+7 -1
@@ -232,7 +232,13 @@ get_remote_refs_for_fetch () {
232 get_remote_merge_branch () {
233 case "$#" in
234 0|1)
235 - die "internal error: get-remote-merge-branch." ;;
235 + origin="$1"
236 + default=$(get_default_remote)
237 + test -z "$origin" && origin=$default
238 + curr_branch=$(git symbolic-ref -q HEAD)
239 + [ "$origin" = "$default" ] &&
240 + echo $(git for-each-ref --format='%(upstream)' $curr_branch)
241 + ;;
242 *)
243 repo=$1
244 shift
t/t5520-pull.sh
+14
@@ -92,20 +92,34 @@ test_expect_success '--rebase with rebased upstream' '
92
93 git remote add -f me . &&
94 git checkout copy &&
95 + git tag copy-orig &&
96 git reset --hard HEAD^ &&
97 echo conflicting modification > file &&
98 git commit -m conflict file &&
99 git checkout to-rebase &&
100 echo file > file2 &&
101 git commit -m to-rebase file2 &&
102 + git tag to-rebase-orig &&
103 git pull --rebase me copy &&
104 test "conflicting modification" = "$(cat file)" &&
105 test file = $(cat file2)
106
107 '
108
109 +test_expect_success '--rebase with rebased default upstream' '
110 +
111 + git update-ref refs/remotes/me/copy copy-orig &&
112 + git checkout --track -b to-rebase2 me/copy &&
113 + git reset --hard to-rebase-orig &&
114 + git pull --rebase &&
115 + test "conflicting modification" = "$(cat file)" &&
116 + test file = $(cat file2)
117 +
118 +'
119 +
120 test_expect_success 'pull --rebase dies early with dirty working directory' '
121
122 + git checkout to-rebase &&
123 git update-ref refs/remotes/me/copy copy^ &&
124 COPY=$(git rev-parse --verify me/copy) &&
125 git rebase --onto $COPY copy &&