{"thread":{"id":"19719","subject":"[PATCHv2 2/3] parse-remote: support default reflist in get_remote_merge_branch","startedAt":"2009-06-07T09:44:21Z","lastAt":"2009-06-07T18:02:05Z","messageCount":3,"participants":["Santi Béjar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115691","messageId":"1244367862-6306-2-git-send-email-santi@agolina.net","threadId":"19719","inReplyTo":null,"subject":"[PATCHv2 2/3] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-07T09:44:21Z","receivedAt":"2009-06-07T09:44:21Z","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.\n\nAlso add a test to check for this case and another one (failing) to\ntest rebasing two branches on top of a rebased upstream using just\n'git pull --rebase'.\n\nSigned-off-by: Santi Béjar <santi@agolina.net>\n---\nChanges from v1:\n  - Hopefully provide a more useful and correct commit message\n\n git-parse-remote.sh |    8 +++++++-\n t/t5520-pull.sh     |   29 +++++++++++++++++++++++++++++\n 2 files changed, 36 insertions(+), 1 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 8b3ba72..5df5689 100644\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..359a3e2 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -92,20 +92,49 @@ 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_failure '--rebase with rebased upstream and two branches' '\n+\n+\tgit update-ref refs/remotes/me/copy copy-orig &&\n+\tgit reset --hard to-rebase-orig &&\n+\tgit checkout --track -b to-rebase3 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+\tgit checkout to-rebase2 &&\n+\tgit pull --rebase me copy\n+\n+'\n+\n test_expect_success 'pull --rebase dies early with dirty working directory' '\n \n+\tgit rebase --abort &&\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"},{"id":"115717","messageId":"7vljo49e08.fsf@alter.siamese.dyndns.org","threadId":"19719","inReplyTo":"1244367862-6306-2-git-send-email-santi@agolina.net","subject":"Re: [PATCHv2 2/3] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-07T16:59:03Z","receivedAt":"2009-06-07T16:59:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi Béjar <santi@agolina.net> writes:\n\n> Expand get_remote_merge_branch to compute the tracking branch to merge\n> when called without arguments (or only the remote name). This allows\n> \"git pull --rebase\" without arguments (default upstream branch) to\n> work with a rebased upstream.\n\nThe last sentence leaves readers wondering...  \"Ok, with this patch, X\nwithout Y now works.  What about X _with_ Y?  Is it left unfixed?  Was it\nalready working before this patch?  What is going on???\"\n\n> Also add a test to check for this case and another one (failing) to\n> test rebasing two branches on top of a rebased upstream using just\n> 'git pull --rebase'.\n\n\"test doing X using just Y\" _sounds as if_ you are implying\n\n\tDoing X using Z (that is more cumbersome to type than Y) works but\n        doing X using Y (that ought to be the equivalent to Z) does not.\n\tLet's expose this inconsistent breakage.\n\nwithout saying what Z is, and/or why Y is preferred.  So if that is what\nis going on, please spell these out.\n\nIf that is not the case please drop \"just\"; it is confusing.\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_failure '--rebase with rebased upstream and two branches' '\n> +\n> +\tgit update-ref refs/remotes/me/copy copy-orig &&\n> +\tgit reset --hard to-rebase-orig &&\n> +\tgit checkout --track -b to-rebase3 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> +\tgit checkout to-rebase2 &&\n> +\tgit pull --rebase me copy\n> +\n> +'\n> +\n>  test_expect_success 'pull --rebase dies early with dirty working directory' '\n>  \n> +\tgit rebase --abort &&\n> +\tgit checkout to-rebase &&\n\nHmm, saying \"--abort\" when rebase is not in progress (i.e. after your next\npatch fixes the above \"expect_failure\" to pass) does not error out?  It is\nnot very nice...\n\n>  \tgit update-ref refs/remotes/me/copy copy^ &&\n>  \tCOPY=$(git rev-parse --verify me/copy) &&\n>  \tgit rebase --onto $COPY copy &&\n> -- \n> 1.6.3.1.308.g426b5\n"},{"id":"115721","messageId":"adf1fd3d0906071102v9c15517v8e7b41a6638a52bb@mail.gmail.com","threadId":"19719","inReplyTo":"7vljo49e08.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 2/3] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-07T18:02:05Z","receivedAt":"2009-06-07T18:02:05Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/6/7 Junio C Hamano <gitster@pobox.com>:\n> Santi Béjar <santi@agolina.net> writes:\n>\n>> Expand get_remote_merge_branch to compute the tracking branch to merge\n>> when called without arguments (or only the remote name). This allows\n>> \"git pull --rebase\" without arguments (default upstream branch) to\n>> work with a rebased upstream.\n>\n> The last sentence leaves readers wondering...  \"Ok, with this patch, X\n> without Y now works.  What about X _with_ Y?  Is it left unfixed?  Was it\n> already working before this patch?  What is going on???\"\n\nNo changes in the \"with Y\" case, so working.\n\nMaybe add the sentence \"( with explicit arguments it already worked)\".\n\n>\n>> Also add a test to check for this case and another one (failing) to\n>> test rebasing two branches on top of a rebased upstream using just\n>> 'git pull --rebase'.\n>\n> \"test doing X using just Y\" _sounds as if_ you are implying\n>\n>        Doing X using Z (that is more cumbersome to type than Y) works but\n>        doing X using Y (that ought to be the equivalent to Z) does not.\n>        Let's expose this inconsistent breakage.\n>\n> without saying what Z is, and/or why Y is preferred.  So if that is what\n> is going on, please spell these out.\n\nIf you have two branches tracking an upstream that is rebased,\ncurrently you have to do:\n\ngit checkout branch1\ngit pull --rebase remote branch\ngit checkout branch2\ngit pull --rebase remote branch\n\nThe second rebase works because the first \"git pull --rebase\" does not\nstore in the local tracking branch the new value, so the second rebase\ndetects that it is rebased.\n\nI think one should be able to do the same without the explicit\narguments to \"git pull --rebase\", but without arguments it stores the\nnew state of the remote branch so the second \"git pull --rebase\" does\nnot work.\n\nI just wanted to single out that it does not currently works.\n\nI see two solutions for this: 1) declare that it is not going to work\nand to do it you have to do the explicit invocation or 2) examine the\nreflog of the remote tracking branch.\n\n> If that is not the case please drop \"just\"; it is confusing.\n\nI'll add some of this explanation to the commit message, and keep the\n\"just\" (they should be equivalent, but are not).\n\n>\n>> +test_expect_success '--rebase with rebased default upstream' '\n>> +\n>> +     git update-ref refs/remotes/me/copy copy-orig &&\n>> +     git checkout --track -b to-rebase2 me/copy &&\n>> +     git reset --hard to-rebase-orig &&\n>> +     git pull --rebase &&\n>> +     test \"conflicting modification\" = \"$(cat file)\" &&\n>> +     test file = $(cat file2)\n>> +\n>> +'\n>> +\n>> +test_expect_failure '--rebase with rebased upstream and two branches' '\n>> +\n>> +     git update-ref refs/remotes/me/copy copy-orig &&\n>> +     git reset --hard to-rebase-orig &&\n>> +     git checkout --track -b to-rebase3 me/copy &&\n>> +     git reset --hard to-rebase-orig &&\n>> +     git pull --rebase &&\n>> +     test \"conflicting modification\" = \"$(cat file)\" &&\n>> +     test file = $(cat file2) &&\n>> +     git checkout to-rebase2 &&\n>> +     git pull --rebase me copy\n>> +\n>> +'\n>> +\n>>  test_expect_success 'pull --rebase dies early with dirty working directory' '\n>>\n>> +     git rebase --abort &&\n>> +     git checkout to-rebase &&\n>\n> Hmm, saying \"--abort\" when rebase is not in progress\n\nThe rebase is in progress (the last test failed)\n\n> (i.e. after your next\n> patch fixes the above \"expect_failure\" to pass) does not error out?  It is\n> not very nice...\n\nMy next patch does not fix the expect_failure, I only wanted to make\nthis behavior explicit. But if at the end this is the prefered\nbehavior (fail rebasing two branches with a rebased upstream) I'll\ndrop this test.\n\nSanti\n"}]}