{"thread":{"id":"9875","subject":"[PATCH 2/3] Don't configure remote \".\" to fetch everything to itself","startedAt":"2007-09-16T06:32:11Z","lastAt":"2007-09-16T06:32:11Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"53170","messageId":"20070916063210.GB6487@spearce.org","threadId":"9875","inReplyTo":null,"subject":"[PATCH 2/3] Don't configure remote \".\" to fetch everything to itself","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-16T06:32:11Z","receivedAt":"2007-09-16T06:32:11Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"When we are talking about a remote URI of \".\" we are really talking\nabout *this* repository that we are fetching into or pushing out of.\nThere are no matching tracking branches for this repository; we\ndo not attempt to map a ref back to ourselves as this would either\ncreate an infinite cycle (for example \"fetch = +refs/*:refs/mine/*\")\nor it causes problems when we attempt to push back to ourselves.\n\nSo we really cannot setup a remote like this:\n\n  [remote \".\"]\n    url = .\n    fetch = +refs/*:refs/*\n\nIn the case of `git push . B:T` to fast-forward branch T to B's\ncurrent commit git-send-pack will update branch T to B, assuming that\nT is the remote tracking branch for B.  This update is performed\nimmediately before git-send-pack asks git-receive-pack to perform\nthe same update, and git-receive-pack then fails because T is not\nwhere git-send-pack told it to expect T to be at.\n\nIn the case of `git fetch .` we really should do the same thing as\n`git fetch $otherrepo`, that is load .git/FETCH_HEAD with the commit\nof HEAD, so that `git pull .` will report \"Already up-to-date\".\nWe have always behaved like this before on this insane request and\nwe should at least continue to behave the same way.  With the above\n(bad) remote configuration we were instead getting fetch errors\nabout funny refs, e.g. \"refs/stash\".\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n This fixes the \"push to yourself\" breakage I mentioned yesterday.\n\n remote.c |    4 ----\n 1 files changed, 0 insertions(+), 4 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex df91b2f..73a34c9 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -356,10 +356,6 @@ struct remote *remote_get(const char *name)\n \t\tadd_uri(ret, name);\n \tif (!ret->uri)\n \t\treturn NULL;\n-\tif (!strcmp(name, \".\")) {\n-\t\t// we always fetch \"refs/*:refs/*\", which is trivial\n-\t\tadd_fetch_refspec(ret, \"refs/*:refs/*\");\n-\t}\n \tret->fetch = parse_ref_spec(ret->fetch_refspec_nr, ret->fetch_refspec);\n \tret->push = parse_ref_spec(ret->push_refspec_nr, ret->push_refspec);\n \treturn ret;\n-- \n1.5.3.1.1000.g7319b\n"}]}