{"thread":{"id":"7233","subject":"[PATCH 2/3] git-fetch: Support the local remote \".\"","startedAt":"2007-03-13T16:28:24Z","lastAt":"2007-03-13T23:01:47Z","messageCount":3,"participants":["Santi Béjar","Paolo Bonzini"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"37010","messageId":"87bqixf6qf.fsf@gmail.com","threadId":"7233","inReplyTo":null,"subject":"[PATCH 2/3] git-fetch: Support the local remote \".\"","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2007-03-13T16:28:24Z","receivedAt":"2007-03-13T16:28:24Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nTo this end, git-parse-remote is grown with a new kind of remote,\n`builtin'. This returns all the local branches in\nget_remote_default_refs_for_fetch. This is equivalent to having a\nfake remote as:\n\n[remote \"local\"]\nurl = .\nfetch = refs/*\n\nBased on a patch from Paolo Bonzini.\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n Documentation/config.txt     |    4 ++++\n git-parse-remote.sh          |   12 +++++++++++-\n t/t5515-fetch-merge-logic.sh |    2 ++\n t/t5515/fetch.br-.           |    6 ++++++\n t/t5515/fetch.br-.-merge     |    6 ++++++\n t/t5515/fetch.br-.-merge_.   |    6 ++++++\n t/t5515/fetch.br-.-octopus   |    6 ++++++\n t/t5515/fetch.br-.-octopus_. |    6 ++++++\n t/t5515/fetch.br-._.         |    6 ++++++\n t/t5515/fetch.br-unconfig_.  |    5 +++++\n t/t5515/fetch.master_.       |    5 +++++\n t/t5520-pull.sh              |   13 +++++++++++++\n 12 files changed, 76 insertions(+), 1 deletions(-)\n create mode 100644 t/t5515/fetch.br-.\n create mode 100644 t/t5515/fetch.br-.-merge\n create mode 100644 t/t5515/fetch.br-.-merge_.\n create mode 100644 t/t5515/fetch.br-.-octopus\n create mode 100644 t/t5515/fetch.br-.-octopus_.\n create mode 100644 t/t5515/fetch.br-._.\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 5408dd6..28899d9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -272,6 +272,10 @@ branch.<name>.merge::\n \t`git fetch`) to lookup the default branch for merging. Without\n \tthis option, `git pull` defaults to merge the first refspec fetched.\n \tSpecify multiple values to get an octopus merge.\n+\tIf you wish to setup `git pull` so that it merges into <name> from\n+\tanother branch in the local repository, you can point\n+\tbranch.<name>.merge to the desired branch, and use the special setting\n+\t`.` (a period) for branch.<name>.remote.\n \n color.branch::\n \tA boolean to enable/disable color in the output of\ndiff --git a/git-parse-remote.sh b/git-parse-remote.sh\nindex 99e7184..84c2c89 100755\n--- a/git-parse-remote.sh\n+++ b/git-parse-remote.sh\n@@ -9,6 +9,9 @@ get_data_source () {\n \t*/*)\n \t\techo ''\n \t\t;;\n+\t.)\n+\t\techo builtin\n+\t\t;;\n \t*)\n \t\tif test \"$(git-config --get \"remote.$1.url\")\"\n \t\tthen\n@@ -31,6 +34,9 @@ get_remote_url () {\n \t'')\n \t\techo \"$1\"\n \t\t;;\n+\tbuiltin)\n+\t\techo \"$1\"\n+\t\t;;\n \tconfig)\n \t\tgit-config --get \"remote.$1.url\"\n \t\t;;\n@@ -57,7 +63,7 @@ get_default_remote () {\n get_remote_default_refs_for_push () {\n \tdata_source=$(get_data_source \"$1\")\n \tcase \"$data_source\" in\n-\t'' | branches)\n+\t'' | branches | builtin)\n \t\t;; # no default push mapping, just send matching refs.\n \tconfig)\n \t\tgit-config --get-all \"remote.$1.push\" ;;\n@@ -128,6 +134,10 @@ get_remote_default_refs_for_fetch () {\n \tcase \"$data_source\" in\n \t'')\n \t\tset explicit \"HEAD:\" ;;\n+\tbuiltin)\n+\t\tset glob $(for name in $(git-show-ref |\n+\t\t\tsed -n 's,.*[      ]refs/,refs/,p')\n+\t\t    do echo \"$name:\" ; done);;\n \tconfig)\n \t\tset $(expand_refs_wildcard \"$1\" \\\n \t\t\t$(git-config --get-all \"remote.$1.fetch\")) ;;\ndiff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh\nindex 9759959..e840fe0 100755\n--- a/t/t5515-fetch-merge-logic.sh\n+++ b/t/t5515-fetch-merge-logic.sh\n@@ -78,6 +78,8 @@ test_expect_success setup '\n \techo \"../.git#one\" > .git/branches/branches-one &&\n \tremotes=\"$remotes branches-one\" &&\n \n+\tremotes=\"$remotes .\" &&\n+\n \tfor remote in $remotes ; do\n \t\tgit config branch.br-$remote.remote $remote &&\n \t\tgit config branch.br-$remote-merge.remote $remote &&\ndiff --git a/t/t5515/fetch.br-. b/t/t5515/fetch.br-.\nnew file mode 100644\nindex 0000000..8878a73\n--- /dev/null\n+++ b/t/t5515/fetch.br-.\n@@ -0,0 +1,6 @@\n+# br-.\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.br-.-merge b/t/t5515/fetch.br-.-merge\nnew file mode 100644\nindex 0000000..b851578\n--- /dev/null\n+++ b/t/t5515/fetch.br-.-merge\n@@ -0,0 +1,6 @@\n+# br-.-merge\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.br-.-merge_. b/t/t5515/fetch.br-.-merge_.\nnew file mode 100644\nindex 0000000..2484570\n--- /dev/null\n+++ b/t/t5515/fetch.br-.-merge_.\n@@ -0,0 +1,6 @@\n+# br-.-merge .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.br-.-octopus b/t/t5515/fetch.br-.-octopus\nnew file mode 100644\nindex 0000000..3f440b1\n--- /dev/null\n+++ b/t/t5515/fetch.br-.-octopus\n@@ -0,0 +1,6 @@\n+# br-.-octopus\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.br-.-octopus_. b/t/t5515/fetch.br-.-octopus_.\nnew file mode 100644\nindex 0000000..938e9ed\n--- /dev/null\n+++ b/t/t5515/fetch.br-.-octopus_.\n@@ -0,0 +1,6 @@\n+# br-.-octopus .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.br-._. b/t/t5515/fetch.br-._.\nnew file mode 100644\nindex 0000000..9d43858\n--- /dev/null\n+++ b/t/t5515/fetch.br-._.\n@@ -0,0 +1,6 @@\n+# br-. .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.br-unconfig_. b/t/t5515/fetch.br-unconfig_.\nindex 73c937d..455a0ce 100644\n--- a/t/t5515/fetch.br-unconfig_.\n+++ b/t/t5515/fetch.br-unconfig_.\n@@ -1 +1,6 @@\n # br-unconfig .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5515/fetch.master_. b/t/t5515/fetch.master_.\nindex ad16cdc..967d057 100644\n--- a/t/t5515/fetch.master_.\n+++ b/t/t5515/fetch.master_.\n@@ -1 +1,6 @@\n # master .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/HEAD' of .\n+754b754407bf032e9a2f9d5a9ad05ca79a6b228f\tnot-for-merge\tremote branch 'origin/master' of .\n+8e32a6d901327a23ef831511badce7bf3bf46689\tnot-for-merge\tremote branch 'origin/one' of .\n+0567da4d5edd2ff4bb292a465ba9e64dcad9536b\tnot-for-merge\tremote branch 'origin/three' of .\n+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8\tnot-for-merge\tremote branch 'origin/two' of .\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex 7eb3783..c424e5b 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -29,5 +29,18 @@ test_expect_success 'checking the results' '\n \tdiff file cloned/file\n '\n \n+test_expect_success 'test . as a remote' '\n+\n+\tgit branch copy master &&\n+\tgit config branch.copy.remote . &&\n+\tgit config branch.copy.merge refs/heads/master &&\n+\techo updated >file &&\n+\tgit commit -a -m updated &&\n+\tgit checkout copy &&\n+\ttest `cat file` = file &&\n+\tgit pull &&\n+\ttest `cat file` = updated\n+'\n+\n test_done\n \n-- \n1.5.0.3.1021.g5897\n"},{"id":"37013","messageId":"45F6D718.5080601@lu.unisi.ch","threadId":"7233","inReplyTo":"87bqixf6qf.fsf@gmail.com","subject":"Re: [PATCH 2/3] git-fetch: Support the local remote \".\"","fromName":"Paolo Bonzini","fromEmail":"paolo.bonzini@lu.unisi.ch","sentAt":"2007-03-13T16:53:44Z","receivedAt":"2007-03-13T16:53:44Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"Santi Béjar wrote:\n> To this end, git-parse-remote is grown with a new kind of remote,\n> `builtin'. This returns all the local branches in\n> get_remote_default_refs_for_fetch. This is equivalent to having a\n> fake remote as:\n> \n> [remote \"local\"]\n> url = .\n> fetch = refs/*\n> \n> Based on a patch from Paolo Bonzini.\n\nCan you please compare the times to do \"git fetch .\"?  The reason\nto touch git-fetch.sh was an optimization that Junio requested.\n\nI found my 2nd submission to be 20% faster than the first.\n\nPaolo\n"},{"id":"37032","messageId":"8aa486160703131601j19c4e3b2nd0a4e8ccd4cc7114@mail.gmail.com","threadId":"7233","inReplyTo":"45F6D718.5080601@lu.unisi.ch","subject":"Re: [PATCH 2/3] git-fetch: Support the local remote \".\"","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2007-03-13T23:01:47Z","receivedAt":"2007-03-13T23:01:47Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On 3/13/07, Paolo Bonzini <paolo.bonzini@lu.unisi.ch> wrote:\n> Santi Béjar wrote:\n> > To this end, git-parse-remote is grown with a new kind of remote,\n> > `builtin'. This returns all the local branches in\n> > get_remote_default_refs_for_fetch. This is equivalent to having a\n> > fake remote as:\n> >\n> > [remote \"local\"]\n> > url = .\n> > fetch = refs/*\n> >\n> > Based on a patch from Paolo Bonzini.\n>\n> Can you please compare the times to do \"git fetch .\"?  The reason\n> to touch git-fetch.sh was an optimization that Junio requested.\n>\n> I found my 2nd submission to be 20% faster than the first.\n>\n> Paolo\n>\n\nYes. But this optimization is independent of this patch, as it already\nexists without this (but it gets worse with this patch).\n\nAlso, I think, the split in fetch_main should be base on transport and\nnot on the definition of the remote.\n\nSanti\n"}]}