{"thread":{"id":"19738","subject":"[PATCHv3 2/4] parse-remote: support default reflist in get_remote_merge_branch","startedAt":"2009-06-08T09:00:49Z","lastAt":"2009-06-08T09:00:49Z","messageCount":1,"participants":["Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115784","messageId":"1244451651-22651-3-git-send-email-santi@agolina.net","threadId":"19738","inReplyTo":null,"subject":"[PATCHv3 2/4] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-08T09:00:49Z","receivedAt":"2009-06-08T09:00:49Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Expand get_remote_merge_branch to compute the tracking branch to merge\nwhen called without arguments (or only the remote name). This allows\n\"git pull --rebase\" without arguments (default upstream branch) to\nwork with a rebased upstream. With explicit arguments it already worked.\n\nAlso add a test to check for this case.\n\nSigned-off-by: Santi Béjar <santi@agolina.net>\n---\nChanges since v1:\n  - Hopefully provide a more useful and correct commit message\nChanges since v2:\n  - Add sentence about the \"with explicit arguments\" case\n  - Move the test about two branch to a different patch\n  - Restore the executable bit\n\n git-parse-remote.sh |    8 +++++++-\n t/t5520-pull.sh     |   14 ++++++++++++++\n 2 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 8b3ba72..5df5689 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -232,7 +232,13 @@ get_remote_refs_for_fetch () {\n get_remote_merge_branch () {\n \tcase \"$#\" in\n \t0|1)\n-\t    die \"internal error: get-remote-merge-branch.\" ;;\n+\t    origin=\"$1\"\n+\t    default=$(get_default_remote)\n+\t    test -z \"$origin\" && origin=$default\n+\t    curr_branch=$(git symbolic-ref -q HEAD)\n+\t    [ \"$origin\" = \"$default\" ] &&\n+\t    echo $(git for-each-ref --format='%(upstream)' $curr_branch)\n+\t    ;;\n \t*)\n \t    repo=$1\n \t    shift\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex 725771f..c5a2e66 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -92,20 +92,34 @@ test_expect_success '--rebase with rebased upstream' '\n \n \tgit remote add -f me . &&\n \tgit checkout copy &&\n+\tgit tag copy-orig &&\n \tgit reset --hard HEAD^ &&\n \techo conflicting modification > file &&\n \tgit commit -m conflict file &&\n \tgit checkout to-rebase &&\n \techo file > file2 &&\n \tgit commit -m to-rebase file2 &&\n+\tgit tag to-rebase-orig &&\n \tgit pull --rebase me copy &&\n \ttest \"conflicting modification\" = \"$(cat file)\" &&\n \ttest file = $(cat file2)\n \n '\n \n+test_expect_success '--rebase with rebased default upstream' '\n+\n+\tgit update-ref refs/remotes/me/copy copy-orig &&\n+\tgit checkout --track -b to-rebase2 me/copy &&\n+\tgit reset --hard to-rebase-orig &&\n+\tgit pull --rebase &&\n+\ttest \"conflicting modification\" = \"$(cat file)\" &&\n+\ttest file = $(cat file2)\n+\n+'\n+\n test_expect_success 'pull --rebase dies early with dirty working directory' '\n \n+\tgit checkout to-rebase &&\n \tgit update-ref refs/remotes/me/copy copy^ &&\n \tCOPY=$(git rev-parse --verify me/copy) &&\n \tgit rebase --onto $COPY copy &&\n-- \n1.6.3.1.308.g426b5\n"}]}