{"thread":{"id":"5667","subject":"[PATCH 0/4 (take 4)] Fetch: branch properties for fetch.","startedAt":"2006-09-23T20:49:27Z","lastAt":"2006-09-24T01:49:41Z","messageCount":6,"participants":["Santi Béjar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"27510","messageId":"87ac4qfgvc.fsf@gmail.com","threadId":"5667","inReplyTo":null,"subject":"[PATCH 0/4 (take 4)] Fetch: branch properties for fetch.","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T20:49:27Z","receivedAt":"2006-09-23T20:49:27Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nHi *,\n\nThis patch series implements the following branch properties for fetch:\n\n - default repository to fetch\n - default remotes branches to merge from the default repository\n\nand adds some tests.\n\nIt passes all the tests.\n\nSanti\n\n---\n Documentation/config.txt |    7 +++++\n git-fetch.sh             |    9 +++---\n git-parse-remote.sh      |   43 ++++++++++++++++++++++++------\n t/t5510-fetch.sh         |   67 ++++++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 113 insertions(+), 13 deletions(-)\n"},{"id":"27512","messageId":"8764fefgta.fsf@gmail.com","threadId":"5667","inReplyTo":"87ac4qfgvc.fsf@gmail.com","subject":"[PATCH 1/4 (take 4)] fetch: default remote repository from branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T20:50:41Z","receivedAt":"2006-09-23T20:50:41Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nIf in branch \"foo\" and this in config:\n\n[branch \"foo\"]\n       remote=bar\n\n\"git fetch\" = \"git fetch bar\"\n\"git  pull\" = \"git pull  bar\"\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/config.txt |    3 +++\n git-fetch.sh             |    9 ++++-----\n git-parse-remote.sh      |    6 ++++++\n 3 files changed, 13 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex bb2fbc3..04c5094 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -119,6 +119,9 @@ apply.whitespace::\n \tTells `git-apply` how to handle whitespaces, in the same way\n \tas the '--whitespace' option. See gitlink:git-apply[1].\n \n+branch.<name>.remote::\n+\tWhen in branch <name>, it tells `git fetch` which remote to fetch.\n+\n pager.color::\n \tA boolean to enable/disable colored output when the pager is in\n \tuse (default is true).\ndiff --git a/git-fetch.sh b/git-fetch.sh\nindex 09a5d6c..50ad101 100755\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -68,11 +68,10 @@ done\n \n case \"$#\" in\n 0)\n-\ttest -f \"$GIT_DIR/branches/origin\" ||\n-\t\ttest -f \"$GIT_DIR/remotes/origin\" ||\n-\t\t\tgit-repo-config --get remote.origin.url >/dev/null ||\n-\t\t\t\tdie \"Where do you want to fetch from today?\"\n-\tset origin ;;\n+\torigin=$(get_default_remote)\n+\ttest -n \"$(get_remote_url ${origin})\" ||\n+\t\tdie \"Where do you want to fetch from today?\"\n+\tset x $origin ; shift ;;\n esac\n \n remote_nick=\"$1\"\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 187f088..6999816 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -68,6 +68,12 @@ get_remote_url () {\n \tesac\n }\n \n+get_default_remote () {\n+\tcurr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')\n+\torigin=$(git-repo-config --get \"branch.$curr_branch.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-- \n1.4.2.1.g279b\n"},{"id":"27513","messageId":"871wq2fgqm.fsf@gmail.com","threadId":"5667","inReplyTo":"87ac4qfgvc.fsf@gmail.com","subject":"[PATCH 2/4 (take 4)] Add t5510 to test per branch configuration affecting git-fetch.","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T20:52:17Z","receivedAt":"2006-09-23T20:52:17Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nFrom: Junio C Hamano <junkio@cox.net>\nSigned-off-by: Junio C Hamano <junkio@cox.net>\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n I hope the attribution is ok.\n\n t/t5510-fetch.sh |   44 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 44 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nnew file mode 100755\nindex 0000000..e71581a\n--- /dev/null\n+++ b/t/t5510-fetch.sh\n@@ -0,0 +1,44 @@\n+#!/bin/sh\n+# Copyright (c) 2006, Junio C Hamano.\n+\n+test_description='Per branch config variables affects \"git fetch\".\n+\n+'\n+\n+. ./test-lib.sh\n+\n+D=`pwd`\n+\n+test_expect_success setup '\n+\techo >file original &&\n+\tgit add file &&\n+\tgit commit -a -m original'\n+\n+test_expect_success \"clone and setup child repos\" '\n+\tgit clone . one &&\n+\tcd one &&\n+\techo >file updated by one &&\n+\tgit commit -a -m \"updated by one\" &&\n+\tcd .. &&\n+\tgit clone . two &&\n+\tcd two &&\n+\tgit repo-config branch.master.remote one &&\n+\t{\n+\t\techo \"URL: ../one/.git/\"\n+\t\techo \"Pull: refs/heads/master:refs/heads/one\"\n+\t} >.git/remotes/one\n+'\n+\n+test_expect_success \"fetch test\" '\n+\tcd \"$D\" &&\n+\techo >file updated by origin &&\n+\tgit commit -a -m \"updated by origin\" &&\n+\tcd two &&\n+\tgit fetch &&\n+\ttest -f .git/refs/heads/one &&\n+\tmine=`git rev-parse refs/heads/one` &&\n+\this=`cd ../one && git rev-parse refs/heads/master` &&\n+\ttest \"z$mine\" = \"z$his\"\n+'\n+\n+test_done\n-- \n1.4.2.1.g279b\n"},{"id":"27514","messageId":"87wt7ue24v.fsf@gmail.com","threadId":"5667","inReplyTo":"87ac4qfgvc.fsf@gmail.com","subject":"[PATCH 3/4 (take 4)] fetch: get the remote branches to merge from the branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T20:53:04Z","receivedAt":"2006-09-23T20:53:04Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nIf in branch \"foo\" and this in config:\n\n[branch \"foo\"]\n      merge=bar\n\n\"git fetch\": fetch from the default repository and program the \"bar\"\n             branch to be merged with pull.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/config.txt |    4 ++++\n git-parse-remote.sh      |   37 +++++++++++++++++++++++++++++--------\n 2 files changed, 33 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 04c5094..98c1f3e 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -122,6 +122,10 @@ apply.whitespace::\n branch.<name>.remote::\n \tWhen in branch <name>, it tells `git fetch` which remote to fetch.\n \n+branch.<name>.merge::\n+\tWhen in branch <name>, it tells `git fetch` the default remote branch\n+\tto be merged.\n+\n pager.color::\n \tA boolean to enable/disable colored output when the pager is in\n \tuse (default is true).\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 6999816..c325ef7 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -92,9 +92,22 @@ get_remote_default_refs_for_push () {\n \n # Subroutine to canonicalize remote:local notation.\n canon_refs_list_for_fetch () {\n-\t# Leave only the first one alone; add prefix . to the rest\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-\tdot_prefix=\n+\tmerge_branches=\n+\tif test \"$1\" = \"-d\"\n+\tthen\n+\t\tshift ; remote=\"$1\" ; shift\n+\t\tif test \"$remote\" = \"$(get_default_remote)\"\n+\t\tthen\n+\t\t\tcurr_branch=$(git-symbolic-ref HEAD | \\\n+\t\t\t    sed -e 's|^refs/heads/||')\n+\t\t\tmerge_branches=$(git-repo-config \\\n+\t\t\t    --get-all \"branch.${curr_branch}.merge\")\n+\t\tfi\n+\tfi\n \tfor ref\n \tdo\n \t\tforce=\n@@ -107,6 +120,18 @@ canon_refs_list_for_fetch () {\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'') remote=HEAD ;;\n \t\trefs/heads/* | refs/tags/* | refs/remotes/*) ;;\n@@ -126,7 +151,6 @@ canon_refs_list_for_fetch () {\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-\t\tdot_prefix=.\n \tdone\n }\n \n@@ -137,7 +161,7 @@ get_remote_default_refs_for_fetch () {\n \t'' | config-partial | branches-partial)\n \t\techo \"HEAD:\" ;;\n \tconfig)\n-\t\tcanon_refs_list_for_fetch \\\n+\t\tcanon_refs_list_for_fetch -d \"$1\" \\\n \t\t\t$(git-repo-config --get-all \"remote.$1.fetch\") ;;\n \tbranches)\n \t\tremote_branch=$(sed -ne '/#/s/.*#//p' \"$GIT_DIR/branches/$1\")\n@@ -145,10 +169,7 @@ get_remote_default_refs_for_fetch () {\n \t\techo \"refs/heads/${remote_branch}:refs/heads/$1\"\n \t\t;;\n \tremotes)\n-\t\t# This prefixes the second and later default refspecs\n-\t\t# with a '.', to signal git-fetch to mark them\n-\t\t# not-for-merge.\n-\t\tcanon_refs_list_for_fetch $(sed -ne '/^Pull: */{\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-- \n1.4.2.1.g279b\n"},{"id":"27515","messageId":"87sliie20o.fsf@gmail.com","threadId":"5667","inReplyTo":"87ac4qfgvc.fsf@gmail.com","subject":"[PATCH 4/4 (take 4)] Add test for the default merges in fetch.","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T20:55:35Z","receivedAt":"2006-09-23T20:55:35Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n t/t5510-fetch.sh |   23 +++++++++++++++++++++++\n 1 files changed, 23 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex e71581a..c7faffe\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -27,6 +27,16 @@ test_expect_success \"clone and setup chi\n \t\techo \"URL: ../one/.git/\"\n \t\techo \"Pull: refs/heads/master:refs/heads/one\"\n \t} >.git/remotes/one\n+\tcd .. &&\n+\tgit clone . three &&\n+\tcd three &&\n+\tgit repo-config branch.master.remote two\n+\tgit repo-config branch.master.merge refs/heads/one\n+\t{\n+\t\techo \"URL: ../two/.git/\"\n+\t\techo \"Pull: refs/heads/master:refs/heads/two\"\n+\t\techo \"Pull: refs/heads/one:refs/heads/one\"\n+\t} >.git/remotes/two\n '\n \n test_expect_success \"fetch test\" '\n@@ -41,4 +51,17 @@ test_expect_success \"fetch test\" '\n \ttest \"z$mine\" = \"z$his\"\n '\n \n+test_expect_success \"fetch test for-merge\" '\n+\tcd \"$D\" &&\n+\tcd three &&\n+\tgit fetch &&\n+\ttest -f .git/refs/heads/two &&\n+\ttest -f .git/refs/heads/one &&\n+\t{\n+\t\techo -e \"not-for-merge\tbranch \\047master\\047 of ../two/\"\n+\t\techo -e \"\tbranch \\047one\\047 of ../two/\"\n+\t} > expected &&\n+\tcut -f 2- .git/FETCH_HEAD > actual &&\n+\tdiff expected actual'\n+\n test_done\n-- \n1.4.2.1.g279b\n"},{"id":"27528","messageId":"7vbqp6m3t6.fsf@assigned-by-dhcp.cox.net","threadId":"5667","inReplyTo":"87sliie20o.fsf@gmail.com","subject":"Re: [PATCH 4/4 (take 4)] Add test for the default merges in fetch.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-24T01:49:41Z","receivedAt":"2006-09-24T01:49:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi Béjar <sbejar@gmail.com> writes:\n\n> +\tcd .. &&\n> +\tgit clone . three &&\n> +\tcd three &&\n> +\tgit repo-config branch.master.remote two\n> +\tgit repo-config branch.master.merge refs/heads/one\n> +\t{\n> +\t\techo \"URL: ../two/.git/\"\n> +\t\techo \"Pull: refs/heads/master:refs/heads/two\"\n> +\t\techo \"Pull: refs/heads/one:refs/heads/one\"\n> +\t} >.git/remotes/two\n>  '\n\nPlease string them with && unless there is a compelling reason\nnot to.\n\nThat would catch a potential error exit from repo-config,\nalthough it is not a focus of this test.  We have caught\nbreakage of parts of the system by tests meant for unrelated\nparts of the system number of times.\n\n> +test_expect_success \"fetch test for-merge\" '\n> +\tcd \"$D\" &&\n> +\tcd three &&\n> +\tgit fetch &&\n> +\ttest -f .git/refs/heads/two &&\n> +\ttest -f .git/refs/heads/one &&\n> +\t{\n> +\t\techo -e \"not-for-merge\tbranch \\047master\\047 of ../two/\"\n> +\t\techo -e \"\tbranch \\047one\\047 of ../two/\"\n> +\t} > expected &&\n> +\tcut -f 2- .git/FETCH_HEAD > actual &&\n> +\tdiff expected actual'\n\nTesting for the explicit implementation detail (namely, the\nhuman readable part of the merge log message per branch) makes\nme feel uneasy.  Also I've stayed away from \"echo -e\" for some\ninexplicable fear of portability issues and I do not see a\nreason to use it here.  Time to learn to use '\\'' perhaps?\n\nI would have:\n\n - arranged branch tips of all the repos that are potentially\n   involved to have different object names;\n\n - checked for the commit object names at the beginning of the\n   resulting FETCH_HEAD and not-for-merge markers;\n\n - ignored the \"branch 'foo' of repo\" log message pieces;.\n\nIn other words, this on top of yours, which I am going to\ncommit.\n\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex 2d8da59..df0ae48 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -30,8 +30,8 @@ test_expect_success \"clone and setup chi\n \tcd .. &&\n \tgit clone . three &&\n \tcd three &&\n-\tgit repo-config branch.master.remote two\n-\tgit repo-config branch.master.merge refs/heads/one\n+\tgit repo-config branch.master.remote two &&\n+\tgit repo-config branch.master.merge refs/heads/one &&\n \t{\n \t\techo \"URL: ../two/.git/\"\n \t\techo \"Pull: refs/heads/master:refs/heads/two\"\n@@ -57,11 +57,13 @@ test_expect_success \"fetch test for-merg\n \tgit fetch &&\n \ttest -f .git/refs/heads/two &&\n \ttest -f .git/refs/heads/one &&\n+\tmaster_in_two=`cd ../two && git rev-parse master` &&\n+\tone_in_two=`cd ../two && git rev-parse one` &&\n \t{\n-\t\techo -e \"not-for-merge\tbranch \\047master\\047 of ../two/\"\n-\t\techo -e \"\tbranch \\047one\\047 of ../two/\"\n-\t} > expected &&\n-\tcut -f 2- .git/FETCH_HEAD > actual &&\n+\t\techo \"$master_in_two\tnot-for-merge\"\n+\t\techo \"$one_in_two\t\"\n+\t} >expected &&\n+\tcut -f -2 .git/FETCH_HEAD >actual &&\n \tdiff expected actual'\n \n test_done\n"}]}