{"thread":{"id":"19703","subject":"[PATCH 1/3] parse-remote: function to get the tracking branch to be merge","startedAt":"2009-06-05T19:53:35Z","lastAt":"2009-06-05T19:53:35Z","messageCount":1,"participants":["Santi Béjar"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"115555","messageId":"1244231617-17754-1-git-send-email-santi@agolina.net","threadId":"19703","inReplyTo":null,"subject":"[PATCH 1/3] parse-remote: function to get the tracking branch to be merge","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-05T19:53:35Z","receivedAt":"2009-06-05T19:53:35Z","isPatch":true,"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 with this new meaning.\n\nNo behavior changes.\n\nSigned-off-by: Santi Béjar <santi@agolina.net>\n---\n git-parse-remote.sh |   33 +++++++++++++++++++++++++++++++++\n git-pull.sh         |    7 ++-----\n 2 files changed, 35 insertions(+), 5 deletions(-)\n mode change 100755 => 100644 git-parse-remote.sh\n\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nold mode 100755\nnew mode 100644\nindex a296719..8b3ba72\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -229,6 +229,38 @@ 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    # FIXME: It should return the tracking branch\n+\t    #        Currently only works with the default mapping\n+\t    for ref\n+\t    do\n+\t\tcase \"$ref\" in\n+\t\t+*)\n+\t\t\tref=$(expr \"z$ref\" : 'z+\\(.*\\)')\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\tcase \"$remote\" in\n+\t\t'' | HEAD ) remote=HEAD ;;\n+\t\theads/*) remote=${remote#heads/} ;;\n+\t\trefs/heads/*) remote=${remote#refs/heads/} ;;\n+\t\trefs/* | tags/* | remotes/* ) break\n+\t\tesac\n+\n+\t\techo \"refs/remotes/$repo/$remote\"\n+\t\tbreak\n+\t    done\n+\t    ;;\n+\tesac\n+}\n+\n resolve_alternates () {\n \t# original URL (xxx.git)\n \ttop_=`expr \"z$1\" : 'z\\([^:]*:/*[^/]*\\)/'`\n@@ -262,3 +294,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.1.308.g426b5\n"}]}