{"thread":{"id":"19778","subject":"[PATCHv4 0/4] git pull --rebase fixes and cleanup","startedAt":"2009-06-11T22:39:17Z","lastAt":"2009-06-12T06:58:07Z","messageCount":9,"participants":["Santi Béjar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"116098","messageId":"1244759961-4750-1-git-send-email-santi@agolina.net","threadId":"19778","inReplyTo":null,"subject":"[PATCHv4 0/4] git pull --rebase fixes and cleanup","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-11T22:39:17Z","receivedAt":"2009-06-11T22:39:17Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Changes since v3:\n  - Extend 1/4 commit message to explain why there are not behavior changes\n\nSanti BÃ©jar (4):\n  parse-remote: function to get the tracking branch to be merge\n  parse-remote: support default reflist in get_remote_merge_branch\n  t5520-pull: --rebase with rebased upstream and two branches\n  parse-remote: remove unused functions\n\n Documentation/git-parse-remote.txt |   20 ----\n git-parse-remote.sh                |  222 ++++-------------------------------\n git-pull.sh                        |    7 +-\n t/t5520-pull.sh                    |   29 +++++\n 4 files changed, 57 insertions(+), 221 deletions(-)\n"},{"id":"116100","messageId":"1244759961-4750-2-git-send-email-santi@agolina.net","threadId":"19778","inReplyTo":"1244759961-4750-1-git-send-email-santi@agolina.net","subject":"[PATCHv4 1/4] parse-remote: function to get the tracking branch to be merge","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-11T22:39:18Z","receivedAt":"2009-06-11T22:39:18Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"The only user of get_remote_refs_for_fetch was \"git pull --rebase\" and\nit only wanted the tracking branch to be merge. So, add a simple\nfunction (get_remote_merge_branch) with this new meaning.\n\nNo behavior changes. The new function behaves like the old code in\n\"git pull --rebase\". In particular, it only works with the default\nrefspec mapping and with remote branches, not tags.\n\nSigned-off-by: Santi Béjar <santi@agolina.net>\n---\n\nChanges since v3:\n  - Explain why the new function does not change the behavior.\n  - Remove the for loop.\n\n git-parse-remote.sh |   29 +++++++++++++++++++++++++++++\n git-pull.sh         |    7 ++-----\n 2 files changed, 31 insertions(+), 5 deletions(-)\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex a296719..a991564 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -229,6 +229,34 @@ get_remote_refs_for_fetch () {\n \tesac\n }\n \n+get_remote_merge_branch () {\n+\tcase \"$#\" in\n+\t0|1)\n+\t    die \"internal error: get-remote-merge-branch.\" ;;\n+\t*)\n+\t    repo=$1\n+\t    shift\n+\t    ref=$1\n+\t    # FIXME: It should return the tracking branch\n+\t    #        Currently only works with the default mapping\n+\t    case \"$ref\" in\n+\t    +*)\n+\t\tref=$(expr \"z$ref\" : 'z+\\(.*\\)')\n+\t\t;;\n+\t    esac\n+\t    expr \"z$ref\" : 'z.*:' >/dev/null || ref=\"${ref}:\"\n+\t    remote=$(expr \"z$ref\" : 'z\\([^:]*\\):')\n+\t    case \"$remote\" in\n+\t    '' | HEAD ) remote=HEAD ;;\n+\t    heads/*) remote=${remote#heads/} ;;\n+\t    refs/heads/*) remote=${remote#refs/heads/} ;;\n+\t    refs/* | tags/* | remotes/* ) remote=\n+\t    esac\n+\n+\t    [ -n \"$remote\" ] && echo \"refs/remotes/$repo/$remote\"\n+\tesac\n+}\n+\n resolve_alternates () {\n \t# original URL (xxx.git)\n \ttop_=`expr \"z$1\" : 'z\\([^:]*:/*[^/]*\\)/'`\n@@ -262,3 +290,4 @@ get_uploadpack () {\n \t\t;;\n \tesac\n }\n+\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 3526153..3cf2663 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -125,12 +125,9 @@ test true = \"$rebase\" && {\n \tdie \"refusing to pull with rebase: your working tree is not up-to-date\"\n \n \t. git-parse-remote &&\n-\torigin=\"$1\"\n-\ttest -z \"$origin\" && origin=$(get_default_remote)\n-\treflist=\"$(get_remote_refs_for_fetch \"$@\" 2>/dev/null |\n-\t\tsed \"s|refs/heads/\\(.*\\):|\\1|\")\" &&\n+\treflist=\"$(get_remote_merge_branch \"$@\" 2>/dev/null)\" &&\n \toldremoteref=\"$(git rev-parse -q --verify \\\n-\t\t\"refs/remotes/$origin/$reflist\")\"\n+\t\t\"$reflist\")\"\n }\n orig_head=$(git rev-parse -q --verify HEAD)\n git fetch $verbosity --update-head-ok \"$@\" || exit 1\n-- \n1.6.3.2.206.g417f7\n"},{"id":"116101","messageId":"1244759961-4750-3-git-send-email-santi@agolina.net","threadId":"19778","inReplyTo":"1244759961-4750-1-git-send-email-santi@agolina.net","subject":"[PATCHv4 2/4] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-11T22:39:19Z","receivedAt":"2009-06-11T22:39:19Z","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---\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 a991564..75e1254 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.2.206.g417f7\n"},{"id":"116099","messageId":"1244759961-4750-4-git-send-email-santi@agolina.net","threadId":"19778","inReplyTo":"1244759961-4750-1-git-send-email-santi@agolina.net","subject":"[PATCHv4 3/4] t5520-pull: --rebase with rebased upstream and two branches","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-11T22:39:20Z","receivedAt":"2009-06-11T22:39:20Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"If 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\nMark this case as test_expect_failure to make people aware of this\nbehavior.\n\nSigned-off-by: Santi Béjar <santi@agolina.net>\n---\nChanges since v3:\n  - Move the \"git rebase --abort\" to the failing test to not polute the\n    next test.\n\nHi,\n\nI just wanted to make people aware of this behavior and then decide if\nthis is the correct behavior. Then we can document it, or try to find a better\nsolution.\n\nSanti\n\n t/t5520-pull.sh |   17 +++++++++++++++++\n 1 files changed, 17 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex c5a2e66..a4ac6d2 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -117,6 +117,23 @@ test_expect_success '--rebase with rebased default upstream' '\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+\ttest_must_fail git pull --rebase &&\n+\tgit rebase --abort &&\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-- \n1.6.3.2.206.g417f7\n"},{"id":"116102","messageId":"1244759961-4750-5-git-send-email-santi@agolina.net","threadId":"19778","inReplyTo":"1244759961-4750-1-git-send-email-santi@agolina.net","subject":"[PATCHv4 4/4] parse-remote: remove unused functions","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-11T22:39:21Z","receivedAt":"2009-06-11T22:39:21Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Signed-off-by: Santi Béjar <santi@agolina.net>\n---\nChanges from v1:\n  - Only remove the functions documentation, not the whole file\n  - Do not remove git-parse-remote from .gitignore\n\n Documentation/git-parse-remote.txt |   20 ----\n git-parse-remote.sh                |  204 ------------------------------------\n 2 files changed, 0 insertions(+), 224 deletions(-)\n\ndiff --git a/Documentation/git-parse-remote.txt b/Documentation/git-parse-remote.txt\nindex cd43069..39d9daa 100644\n--- a/Documentation/git-parse-remote.txt\n+++ b/Documentation/git-parse-remote.txt\n@@ -17,26 +17,6 @@ routines to parse files under $GIT_DIR/remotes/ and\n $GIT_DIR/branches/ and configuration variables that are related\n to fetching, pulling and pushing.\n \n-The primary entry points are:\n-\n-get_remote_refs_for_fetch::\n-\tGiven the list of user-supplied `<repo> <refspec>...`,\n-\treturn the list of refs to fetch after canonicalizing\n-\tthem into `$GIT_DIR` relative paths\n-\t(e.g. `refs/heads/foo`).  When `<refspec>...` is empty\n-\tthe returned list of refs consists of the defaults\n-\tfor the given `<repo>`, if specified in\n-\t`$GIT_DIR/remotes/`, `$GIT_DIR/branches/`, or `remote.*.fetch`\n-\tconfiguration.\n-\n-get_remote_refs_for_push::\n-\tGiven the list of user-supplied `<repo> <refspec>...`,\n-\treturn the list of refs to push in a form suitable to be\n-\tfed to the 'git-send-pack' command.  When `<refspec>...`\n-\tis empty the returned list of refs consists of the\n-\tdefaults for the given `<repo>`, if specified in\n-\t`$GIT_DIR/remotes/`.\n-\n Author\n ------\n Written by Junio C Hamano.\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 75e1254..5f47b18 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -60,175 +60,6 @@ get_default_remote () {\n \techo ${origin:-origin}\n }\n \n-get_remote_default_refs_for_push () {\n-\tdata_source=$(get_data_source \"$1\")\n-\tcase \"$data_source\" in\n-\t'' | branches | self)\n-\t\t;; # no default push mapping, just send matching refs.\n-\tconfig)\n-\t\tgit config --get-all \"remote.$1.push\" ;;\n-\tremotes)\n-\t\tsed -ne '/^Push: */{\n-\t\t\ts///p\n-\t\t}' \"$GIT_DIR/remotes/$1\" ;;\n-\t*)\n-\t\tdie \"internal error: get-remote-default-ref-for-push $1\" ;;\n-\tesac\n-}\n-\n-# Called from canon_refs_list_for_fetch -d \"$remote\", which\n-# is called from get_remote_default_refs_for_fetch to grok\n-# refspecs that are retrieved from the configuration, but not\n-# from get_remote_refs_for_fetch when it deals with refspecs\n-# supplied on the command line.  $ls_remote_result has the list\n-# of refs available at remote.\n-#\n-# The first token returned is either \"explicit\" or \"glob\"; this\n-# is to help prevent randomly \"globbed\" ref from being chosen as\n-# a merge candidate\n-expand_refs_wildcard () {\n-\techo \"$ls_remote_result\" |\n-\tgit fetch--tool expand-refs-wildcard \"-\" \"$@\"\n-}\n-\n-# Subroutine to canonicalize remote:local notation.\n-canon_refs_list_for_fetch () {\n-\t# If called from get_remote_default_refs_for_fetch\n-\t# leave the branches in branch.${curr_branch}.merge alone,\n-\t# or the first one otherwise; add prefix . to the rest\n-\t# to prevent the secondary branches to be merged by default.\n-\tmerge_branches=\n-\tcurr_branch=\n-\tif test \"$1\" = \"-d\"\n-\tthen\n-\t\tshift ; remote=\"$1\" ; shift\n-\t\tset $(expand_refs_wildcard \"$remote\" \"$@\")\n-\t\tis_explicit=\"$1\"\n-\t\tshift\n-\t\tif test \"$remote\" = \"$(get_default_remote)\"\n-\t\tthen\n-\t\t\tcurr_branch=$(git symbolic-ref -q HEAD | \\\n-\t\t\t    sed -e 's|^refs/heads/||')\n-\t\t\tmerge_branches=$(git config \\\n-\t\t\t    --get-all \"branch.${curr_branch}.merge\")\n-\t\tfi\n-\t\tif test -z \"$merge_branches\" && test $is_explicit != explicit\n-\t\tthen\n-\t\t\tmerge_branches=..this.will.never.match.any.ref..\n-\t\tfi\n-\tfi\n-\tfor ref\n-\tdo\n-\t\tforce=\n-\t\tcase \"$ref\" in\n-\t\t+*)\n-\t\t\tref=$(expr \"z$ref\" : 'z+\\(.*\\)')\n-\t\t\tforce=+\n-\t\t\t;;\n-\t\tesac\n-\t\texpr \"z$ref\" : 'z.*:' >/dev/null || ref=\"${ref}:\"\n-\t\tremote=$(expr \"z$ref\" : 'z\\([^:]*\\):')\n-\t\tlocal=$(expr \"z$ref\" : 'z[^:]*:\\(.*\\)')\n-\t\tdot_prefix=.\n-\t\tif test -z \"$merge_branches\"\n-\t\tthen\n-\t\t\tmerge_branches=$remote\n-\t\t\tdot_prefix=\n-\t\telse\n-\t\t\tfor merge_branch in $merge_branches\n-\t\t\tdo\n-\t\t\t    [ \"$remote\" = \"$merge_branch\" ] &&\n-\t\t\t    dot_prefix= && break\n-\t\t\tdone\n-\t\tfi\n-\t\tcase \"$remote\" in\n-\t\t'' | HEAD ) remote=HEAD ;;\n-\t\trefs/*) ;;\n-\t\theads/* | tags/* | remotes/* ) remote=\"refs/$remote\" ;;\n-\t\t*) remote=\"refs/heads/$remote\" ;;\n-\t\tesac\n-\t\tcase \"$local\" in\n-\t\t'') local= ;;\n-\t\trefs/*) ;;\n-\t\theads/* | tags/* | remotes/* ) local=\"refs/$local\" ;;\n-\t\t*) local=\"refs/heads/$local\" ;;\n-\t\tesac\n-\n-\t\tif local_ref_name=$(expr \"z$local\" : 'zrefs/\\(.*\\)')\n-\t\tthen\n-\t\t   git check-ref-format \"$local_ref_name\" ||\n-\t\t   die \"* refusing to create funny ref '$local_ref_name' locally\"\n-\t\tfi\n-\t\techo \"${dot_prefix}${force}${remote}:${local}\"\n-\tdone\n-}\n-\n-# Returns list of src: (no store), or src:dst (store)\n-get_remote_default_refs_for_fetch () {\n-\tdata_source=$(get_data_source \"$1\")\n-\tcase \"$data_source\" in\n-\t'')\n-\t\techo \"HEAD:\" ;;\n-\tself)\n-\t        canon_refs_list_for_fetch -d \"$1\" \\\n-\t\t\t$(git for-each-ref --format='%(refname):')\n-\t\t;;\n-\tconfig)\n-\t\tcanon_refs_list_for_fetch -d \"$1\" \\\n-\t\t\t$(git config --get-all \"remote.$1.fetch\") ;;\n-\tbranches)\n-\t\tremote_branch=$(sed -ne '/#/s/.*#//p' \"$GIT_DIR/branches/$1\")\n-\t\tcase \"$remote_branch\" in '') remote_branch=master ;; esac\n-\t\techo \"refs/heads/${remote_branch}:refs/heads/$1\"\n-\t\t;;\n-\tremotes)\n-\t\tcanon_refs_list_for_fetch -d \"$1\" $(sed -ne '/^Pull: */{\n-\t\t\t\t\t\ts///p\n-\t\t\t\t\t}' \"$GIT_DIR/remotes/$1\")\n-\t\t;;\n-\t*)\n-\t\tdie \"internal error: get-remote-default-ref-for-fetch $1\" ;;\n-\tesac\n-}\n-\n-get_remote_refs_for_push () {\n-\tcase \"$#\" in\n-\t0) die \"internal error: get-remote-refs-for-push.\" ;;\n-\t1) get_remote_default_refs_for_push \"$@\" ;;\n-\t*) shift; echo \"$@\" ;;\n-\tesac\n-}\n-\n-get_remote_refs_for_fetch () {\n-\tcase \"$#\" in\n-\t0)\n-\t    die \"internal error: get-remote-refs-for-fetch.\" ;;\n-\t1)\n-\t    get_remote_default_refs_for_fetch \"$@\" ;;\n-\t*)\n-\t    shift\n-\t    tag_just_seen=\n-\t    for ref\n-\t    do\n-\t\tif test \"$tag_just_seen\"\n-\t\tthen\n-\t\t    echo \"refs/tags/${ref}:refs/tags/${ref}\"\n-\t\t    tag_just_seen=\n-\t\t    continue\n-\t\telse\n-\t\t    case \"$ref\" in\n-\t\t    tag)\n-\t\t\ttag_just_seen=yes\n-\t\t\tcontinue\n-\t\t\t;;\n-\t\t    esac\n-\t\tfi\n-\t\tcanon_refs_list_for_fetch \"$ref\"\n-\t    done\n-\t    ;;\n-\tesac\n-}\n-\n get_remote_merge_branch () {\n \tcase \"$#\" in\n \t0|1)\n@@ -262,38 +93,3 @@ get_remote_merge_branch () {\n \t    [ -n \"$remote\" ] && echo \"refs/remotes/$repo/$remote\"\n \tesac\n }\n-\n-resolve_alternates () {\n-\t# original URL (xxx.git)\n-\ttop_=`expr \"z$1\" : 'z\\([^:]*:/*[^/]*\\)/'`\n-\twhile read path\n-\tdo\n-\t\tcase \"$path\" in\n-\t\t\\#* | '')\n-\t\t\tcontinue ;;\n-\t\t/*)\n-\t\t\techo \"$top_$path/\" ;;\n-\t\t../*)\n-\t\t\t# relative -- ugly but seems to work.\n-\t\t\techo \"$1/objects/$path/\" ;;\n-\t\t*)\n-\t\t\t# exit code may not be caught by the reader.\n-\t\t\techo \"bad alternate: $path\"\n-\t\t\texit 1 ;;\n-\t\tesac\n-\tdone\n-}\n-\n-get_uploadpack () {\n-\tdata_source=$(get_data_source \"$1\")\n-\tcase \"$data_source\" in\n-\tconfig)\n-\t\tuplp=$(git config --get \"remote.$1.uploadpack\")\n-\t\techo ${uplp:-git-upload-pack}\n-\t\t;;\n-\t*)\n-\t\techo \"git-upload-pack\"\n-\t\t;;\n-\tesac\n-}\n-\n-- \n1.6.3.2.206.g417f7\n"},{"id":"116105","messageId":"7vhbymfjev.fsf@alter.siamese.dyndns.org","threadId":"19778","inReplyTo":"1244759961-4750-4-git-send-email-santi@agolina.net","subject":"Re: [PATCHv4 3/4] t5520-pull: --rebase with rebased upstream and two branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-11T23:19:20Z","receivedAt":"2009-06-11T23:19:20Z","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> If you have two branches tracking an upstream that is rebased,\n> currently you have to do:\n>\n> git checkout branch1\n> git pull --rebase remote branch\n> git checkout branch2\n> git pull --rebase remote branch\n\nI think the \"ah, I see it rebased\" computation is done at a wrong place\nfor the above to work.  You do not even have to do two pull--rebase; I\nthink you can simply do \"git fetch; git pull --rebase\" to break it.\n\nMy understanding of the current code we have since c85c7927 is that it was\ndone as a quick-and-dirty hack that is merely good enough for CVS style\nhistory where everybody is linear.  Grabbing where it used to be last time\nwe looked at before the fetch, and assuming it is the correct original\nfork point, will never work, if you updated the remote tracking ref\noutside of the current invocation of \"pull --rebase\" (if everybody is\nlinear, you by definition have one single branch, so in that special case,\nthe hack may happen to work, if you do not fetch).\n\nIf you want to fix this, I think you need to use the knowledge of where\nthe tip of remote/$origin/$branch used to be.  That is kept in the reflog\nof that remote tracking ref.  So perhaps\n\n (0) Lose \"oldremoteref=...\" before \"git fetch\" happens in git-pull.sh;\n\n (1) just before \"exec git-rebase\", check rtb@{1} is an ancestor of rtb,\n     if so be happy;\n\n (2) otherwise, in the same place, for some (hopefully small) posint n,\n     see if rtb@{n} is an ancestor of rtb; use that as the \"oldremoteref\"\n     when invoking \"git-rebase\".\n\nwhere rtb == remote tracking branch.\n"},{"id":"116115","messageId":"7vvdn2cg6o.fsf@alter.siamese.dyndns.org","threadId":"19778","inReplyTo":"1244759961-4750-4-git-send-email-santi@agolina.net","subject":"Re: [PATCHv4 3/4] t5520-pull: --rebase with rebased upstream and two branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-12T02:57:19Z","receivedAt":"2009-06-12T02:57:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I think marking breakages here is a good thing to do, but I do not think\nthis belongs to your rest of the series.  If a fix for this will upcoming\n(I think I've outlined ideas in a separate message, IIRC), I think that\ncould go to 'maint', to which the remainder of your series will definitely\nnot belong to.\n\nI'd queue this one separately from the other three patches (which will\nfork from 'master'), which means this should not depend on [2/4], but\nunfortunately it does.\n"},{"id":"116116","messageId":"7vocsucfn7.fsf@alter.siamese.dyndns.org","threadId":"19778","inReplyTo":"1244759961-4750-3-git-send-email-santi@agolina.net","subject":"Re: [PATCHv4 2/4] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-12T03:09:00Z","receivedAt":"2009-06-12T03:09:00Z","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).\n\nI've queued this series (sans 3/4--see other message), but I am wondering\nif this has the same \"only works with the defeault layout\" issue and if so\nif it should be documented more clearly.\n\nWhat plumbing support do you need to get the information in a more precise\nway in the scripted Porcelain?  Is exposing branch_get() from remote.c\nenough?  That is what is used by fill_tracking_info() in builtin-branch.c\nand the call to format_tracking_info() remote.c made by report_tracking()\nin builtin-checkout.c --- they are used to produce the \"Your branch is\nahead of that branch you are tracking\" messages.\n"},{"id":"116125","messageId":"adf1fd3d0906112358oad66387u46765919b63af816@mail.gmail.com","threadId":"19778","inReplyTo":"7vocsucfn7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv4 2/4] parse-remote: support default reflist in get_remote_merge_branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-12T06:58:07Z","receivedAt":"2009-06-12T06:58:07Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/6/12 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).\n>\n> I've queued this series (sans 3/4--see other message), but I am wondering\n> if this has the same \"only works with the defeault layout\" issue and if so\n> if it should be documented more clearly.\n\nAs it uses:\n\ngit for-each-ref --format='%(upstream)' $curr_branch\n\nit works with any layout, AFAICS.\n\n>\n> What plumbing support do you need to get the information in a more precise\n> way in the scripted Porcelain?  Is exposing branch_get() from remote.c\n> enough?  That is what is used by fill_tracking_info() in builtin-branch.c\n> and the call to format_tracking_info() remote.c made by report_tracking()\n> in builtin-checkout.c --- they are used to produce the \"Your branch is\n> ahead of that branch you are tracking\" messages.\n\nFor the explicit case I would need something similar, given the remote\nname and the remote branch return the tracking branch, as is currently\ndone in branch_get() but with the remote.$branch.remote and\nremote.$branch.merge as input.\n\nThanks,\nSanti\n"}]}