{"thread":{"id":"10245","subject":"[PATCH] fetch: if not fetching from default remote, ignore default merge","startedAt":"2007-10-11T00:47:55Z","lastAt":"2007-10-11T11:35:59Z","messageCount":4,"participants":["Johannes Schindelin","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"55443","messageId":"Pine.LNX.4.64.0710110146200.4174@racer.site","threadId":"10245","inReplyTo":null,"subject":"[PATCH] fetch: if not fetching from default remote, ignore default merge","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-11T00:47:55Z","receivedAt":"2007-10-11T00:47:55Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen doing \"git fetch <remote>\" on a remote that does not have the\nbranch referenced in branch.<current-branch>.merge, git fetch failed.\nIt failed because it tried to add the \"merge\" ref to the refs to be\nfetched.\n\nFix that.  And add a test case.\n\nIncidentally, this unconvered a bug in our own test suite, where\n\"git pull <some-path>\" was expected to merge the ref given in the\ndefaults, even if not pulling from the default remote.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin-fetch.c            |    8 +++++++-\n t/t5510-fetch.sh           |    8 ++++++++\n t/t5700-clone-reference.sh |    4 ++--\n 3 files changed, 17 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex cf7498b..ca4de9f 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -105,7 +105,13 @@ static struct ref *get_ref_map(struct transport *transport,\n \t\t\t\t    !remote->fetch[0].pattern)\n \t\t\t\t\tref_map->merge = 1;\n \t\t\t}\n-\t\t\tif (has_merge)\n+\t\t\t/*\n+\t\t\t * if the remote we're fetching from is the same\n+\t\t\t * as given in branch.<name>.remote, we add the\n+\t\t\t * ref given in branch.<name>.merge, too.\n+\t\t\t */\n+\t\t\tif (has_merge && !strcmp(branch->remote_name,\n+\t\t\t\t\t\tremote->name))\n \t\t\t\tadd_merge_config(&ref_map, remote_refs, branch, &tail);\n \t\t} else {\n \t\t\tref_map = get_remote_ref(remote_refs, \"HEAD\");\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex 73a4e3c..755d809 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -188,4 +188,12 @@ test_expect_success 'push via rsync' '\n '\n }\n \n+test_expect_success 'fetch with a non-applying branch.<name>.merge' '\n+\tgit config branch.master.remote yeti &&\n+\tgit config branch.master.merge refs/heads/bigfoot &&\n+\tgit config remote.blub.url one &&\n+\tgit config remote.blub.fetch 'refs/heads/*:refs/remotes/one/*' &&\n+\tgit fetch blub\n+'\n+\n test_done\ndiff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh\nindex 4e93aaa..b6a5486 100755\n--- a/t/t5700-clone-reference.sh\n+++ b/t/t5700-clone-reference.sh\n@@ -38,7 +38,7 @@ cd \"$base_dir\"\n \n test_expect_success 'pulling from reference' \\\n 'cd C &&\n-git pull ../B'\n+git pull ../B master'\n \n cd \"$base_dir\"\n \n@@ -61,7 +61,7 @@ test_expect_success 'existence of info/alternates' \\\n cd \"$base_dir\"\n \n test_expect_success 'pulling from reference' \\\n-'cd D && git pull ../B'\n+'cd D && git pull ../B master'\n \n cd \"$base_dir\"\n \n-- \n1.5.3.4.1169.g5fb8d\n"},{"id":"55449","messageId":"470DC53A.4050707@viscovery.net","threadId":"10245","inReplyTo":"Pine.LNX.4.64.0710110146200.4174@racer.site","subject":"Re: [PATCH] fetch: if not fetching from default remote, ignore default merge","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-10-11T06:39:54Z","receivedAt":"2007-10-11T06:39:54Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Johannes Schindelin schrieb:\n> +test_expect_success 'fetch with a non-applying branch.<name>.merge' '\n> +\tgit config branch.master.remote yeti &&\n> +\tgit config branch.master.merge refs/heads/bigfoot &&\n> +\tgit config remote.blub.url one &&\n> +\tgit config remote.blub.fetch 'refs/heads/*:refs/remotes/one/*' &&\n\nBetter use double-quotes around the refspecs.\n\n> +\tgit fetch blub\n> +'\n> +\n\n-- Hannes\n"},{"id":"55461","messageId":"Pine.LNX.4.64.0710111233280.4174@racer.site","threadId":"10245","inReplyTo":"470DC53A.4050707@viscovery.net","subject":"Re: [PATCH] fetch: if not fetching from default remote, ignore default merge","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-11T11:34:28Z","receivedAt":"2007-10-11T11:34:28Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 11 Oct 2007, Johannes Sixt wrote:\n\n> Johannes Schindelin schrieb:\n> > +test_expect_success 'fetch with a non-applying branch.<name>.merge' '\n> > +\tgit config branch.master.remote yeti &&\n> > +\tgit config branch.master.merge refs/heads/bigfoot &&\n> > +\tgit config remote.blub.url one &&\n> > +\tgit config remote.blub.fetch 'refs/heads/*:refs/remotes/one/*' &&\n> \n> Better use double-quotes around the refspecs.\n\nHehe, \"oops!\".\n\nAlthough in this case we could even use the string unquoted (which I \nindeed did!), since there is no chance that there is a matching file in \nt/trash/.\n\nCiao,\nDscho\n"},{"id":"55462","messageId":"Pine.LNX.4.64.0710111235440.4174@racer.site","threadId":"10245","inReplyTo":"470DC53A.4050707@viscovery.net","subject":"[PATCH v2] fetch: if not fetching from default remote, ignore default merge","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-11T11:35:59Z","receivedAt":"2007-10-11T11:35:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen doing \"git fetch <remote>\" on a remote that does not have the\nbranch referenced in branch.<current-branch>.merge, git fetch failed.\nIt failed because it tried to add the \"merge\" ref to the refs to be\nfetched.\n\nFix that.  And add a test case.\n\nIncidentally, this unconvered a bug in our own test suite, where\n\"git pull <some-path>\" was expected to merge the ref given in the\ndefaults, even if not pulling from the default remote.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin-fetch.c            |    8 +++++++-\n t/t5510-fetch.sh           |    8 ++++++++\n t/t5700-clone-reference.sh |    4 ++--\n 3 files changed, 17 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex cf7498b..ca4de9f 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -105,7 +105,13 @@ static struct ref *get_ref_map(struct transport *transport,\n \t\t\t\t    !remote->fetch[0].pattern)\n \t\t\t\t\tref_map->merge = 1;\n \t\t\t}\n-\t\t\tif (has_merge)\n+\t\t\t/*\n+\t\t\t * if the remote we're fetching from is the same\n+\t\t\t * as given in branch.<name>.remote, we add the\n+\t\t\t * ref given in branch.<name>.merge, too.\n+\t\t\t */\n+\t\t\tif (has_merge && !strcmp(branch->remote_name,\n+\t\t\t\t\t\tremote->name))\n \t\t\t\tadd_merge_config(&ref_map, remote_refs, branch, &tail);\n \t\t} else {\n \t\t\tref_map = get_remote_ref(remote_refs, \"HEAD\");\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex 73a4e3c..1f398bc 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -188,4 +188,12 @@ test_expect_success 'push via rsync' '\n '\n }\n \n+test_expect_success 'fetch with a non-applying branch.<name>.merge' '\n+\tgit config branch.master.remote yeti &&\n+\tgit config branch.master.merge refs/heads/bigfoot &&\n+\tgit config remote.blub.url one &&\n+\tgit config remote.blub.fetch \"refs/heads/*:refs/remotes/one/*\" &&\n+\tgit fetch blub\n+'\n+\n test_done\ndiff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh\nindex 4e93aaa..b6a5486 100755\n--- a/t/t5700-clone-reference.sh\n+++ b/t/t5700-clone-reference.sh\n@@ -38,7 +38,7 @@ cd \"$base_dir\"\n \n test_expect_success 'pulling from reference' \\\n 'cd C &&\n-git pull ../B'\n+git pull ../B master'\n \n cd \"$base_dir\"\n \n@@ -61,7 +61,7 @@ test_expect_success 'existence of info/alternates' \\\n cd \"$base_dir\"\n \n test_expect_success 'pulling from reference' \\\n-'cd D && git pull ../B'\n+'cd D && git pull ../B master'\n \n cd \"$base_dir\"\n \n-- \n1.5.3.4.1174.gcd0d6-dirty\n"}]}