{"thread":{"id":"5659","subject":"[PATCH 0/2 (take 3)] Fetch: branch properties.","startedAt":"2006-09-23T10:04:37Z","lastAt":"2006-09-23T10:43:35Z","messageCount":5,"participants":["Santi Béjar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"27460","messageId":"87venex5je.fsf@gmail.com","threadId":"5659","inReplyTo":null,"subject":"[PATCH 0/2 (take 3)] Fetch: branch properties.","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T10:04:37Z","receivedAt":"2006-09-23T10:04:37Z","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\n Documentation/config.txt |    7 +++++++\n git-fetch.sh             |    9 ++++-----\n git-parse-remote.sh      |   34 ++++++++++++++++++++++++++--------\n 3 files changed, 37 insertions(+), 13 deletions(-)\n\n Santi\n"},{"id":"27461","messageId":"87r6y2x5hk.fsf@gmail.com","threadId":"5659","inReplyTo":"87venex5je.fsf@gmail.com","subject":"[PATCH 1/2] Fetch: default remote repository from branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T10:05:43Z","receivedAt":"2006-09-23T10:05:43Z","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.g94da7\n"},{"id":"27462","messageId":"877izux5d2.fsf@gmail.com","threadId":"5659","inReplyTo":"87venex5je.fsf@gmail.com","subject":"[PATCH 2/2] Fetch: get the remote branches to merge from the branch properties","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2006-09-23T10:08:25Z","receivedAt":"2006-09-23T10:08:25Z","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      |   30 ++++++++++++++++++++++--------\n 2 files changed, 26 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..d3a1b9a 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+\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+\t[ -z \"$merge_branches\" ] && merge_branches=$1\n \tfor ref\n \tdo\n \t\tforce=\n@@ -107,6 +120,11 @@ 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\tfor merge_branch in $merge_branches\n+\t\tdo\n+\t\t    [ \"$remote\" = \"$merge_branch\" ] && dot_prefix= && break\n+\t\tdone\n \t\tcase \"$remote\" in\n \t\t'') remote=HEAD ;;\n \t\trefs/heads/* | refs/tags/* | refs/remotes/*) ;;\n@@ -126,7 +144,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 +154,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 +162,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.g94da7\n"},{"id":"27463","messageId":"7vr6y2uaqi.fsf@assigned-by-dhcp.cox.net","threadId":"5659","inReplyTo":"87r6y2x5hk.fsf@gmail.com","subject":"Re: [PATCH 1/2] Fetch: default remote repository from branch properties","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-23T10:40:37Z","receivedAt":"2006-09-23T10:40:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"You would need a new test in the testsuite for this.\n\n-- >8 --\n[PATCH] Add t5510 to test per branch configuration affecting git-fetch.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\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.ga89e\n"},{"id":"27464","messageId":"7vfyeiualk.fsf@assigned-by-dhcp.cox.net","threadId":"5659","inReplyTo":"877izux5d2.fsf@gmail.com","subject":"Re: [PATCH 2/2] Fetch: get the remote branches to merge from the branch properties","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-23T10:43:35Z","receivedAt":"2006-09-23T10:43:35Z","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> If 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>\n> Signed-off-by: Santi Béjar <sbejar@gmail.com>\n\nThis still breaks t5700 test the same way as the earlier one.\n"}]}