{"thread":{"id":"8464","subject":"[PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","startedAt":"2007-06-06T07:45:21Z","lastAt":"2007-06-06T22:48:41Z","messageCount":9,"participants":["Alex Riesen","Junio C Hamano","J Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"44132","messageId":"81b0412b0706060045k4098eb05tc596214f8d9673bf@mail.gmail.com","threadId":"8464","inReplyTo":null,"subject":"[PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-06T07:45:21Z","receivedAt":"2007-06-06T07:45:21Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Otherwise \".git\" is removed from every remote name which has it:\n\n  $ git fetch -v\n    * refs/heads/origin: same as branch 'master' of /home/user/linux\n      commit: 5ecd310\n  $ ls /home/user/linux\n  ls: /home/user/linux: No such file or directory\n  $ ls /home/user/linux.git\n  HEAD  objects  packed-refs  ...\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n builtin-fetch--tool.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\n\nFrom 100742821619fdd83e75aa8dcb88489aa4b60648 Mon Sep 17 00:00:00 2001\nFrom: Alex Riesen <raa@limbo.localdomain>\nDate: Wed, 6 Jun 2007 00:16:14 +0200\nSubject: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference\n\nOtherwise \".git\" is removed from every remote name which has it:\n\n  $ git fetch -v\n    * refs/heads/origin: same as branch 'master' of /home/user/linux\n      commit: 5ecd310\n  $ ls /home/user/linux\n  ls: /home/user/linux: No such file or directory\n  $ ls /home/user/linux.git\n  HEAD  objects  packed-refs  ...\n\nSigned-off-by: Alex Riesen <raa@limbo.localdomain>\n---\n builtin-fetch--tool.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c\nindex ed4d5de..22ca125 100644\n--- a/builtin-fetch--tool.c\n+++ b/builtin-fetch--tool.c\n@@ -140,7 +140,7 @@ static int append_fetch_head(FILE *fp,\n \t\t\t     int verbose, int force)\n {\n \tstruct commit *commit;\n-\tint remote_len, i, note_len;\n+\tint remote_len, note_len;\n \tunsigned char sha1[20];\n \tchar note[1024];\n \tconst char *what, *kind;\n@@ -173,11 +173,11 @@ static int append_fetch_head(FILE *fp,\n \t}\n \n \tremote_len = strlen(remote);\n-\tfor (i = remote_len - 1; remote[i] == '/' && 0 <= i; i--)\n-\t\t;\n-\tremote_len = i + 1;\n-\tif (4 < i && !strncmp(\".git\", remote + i - 3, 4))\n-\t\tremote_len = i - 3;\n+\tif (remote_len > 5) {\n+\t\tchar *p = strrchr(remote, '/');\n+\t\tif (p && !strcmp(p, \"/.git\"))\n+\t\t    remote_len -= 4;\n+\t}\n \n \tnote_len = 0;\n \tif (*what) {\n-- \n1.5.2.1.134.g352b\n\n"},{"id":"44137","messageId":"7v3b157b4j.fsf@assigned-by-dhcp.cox.net","threadId":"8464","inReplyTo":"81b0412b0706060045k4098eb05tc596214f8d9673bf@mail.gmail.com","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-06T08:14:36Z","receivedAt":"2007-06-06T08:14:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> Otherwise \".git\" is removed from every remote name which has it:\n>\n>  $ git fetch -v\n>    * refs/heads/origin: same as branch 'master' of /home/user/linux\n>      commit: 5ecd310\n>  $ ls /home/user/linux\n>  ls: /home/user/linux: No such file or directory\n>  $ ls /home/user/linux.git\n>  HEAD  objects  packed-refs  ...\n\nI suspect the above misses the point.\n\nThe test \"ls /home/user/linux\" is not relevant.  Ability to say\n\"git fetch /home/user/linux\" is.\n"},{"id":"44143","messageId":"81b0412b0706060142h2df41f11pa0157a360831736@mail.gmail.com","threadId":"8464","inReplyTo":"7v3b157b4j.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-06T08:42:15Z","receivedAt":"2007-06-06T08:42:15Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 6/6/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Alex Riesen\" <raa.lkml@gmail.com> writes:\n>\n> > Otherwise \".git\" is removed from every remote name which has it:\n> >\n> >  $ git fetch -v\n> >    * refs/heads/origin: same as branch 'master' of /home/user/linux\n> >      commit: 5ecd310\n> >  $ ls /home/user/linux\n> >  ls: /home/user/linux: No such file or directory\n> >  $ ls /home/user/linux.git\n> >  HEAD  objects  packed-refs  ...\n>\n> I suspect the above misses the point.\n\nDepends on the point. I mean to say: the path in the output\nof the command does not exist anywhere.\n\n> The test \"ls /home/user/linux\" is not relevant.  Ability to say\n> \"git fetch /home/user/linux\" is.\n\nThis is still ambiguous:\n\n$ git fetch -v /home/user/a\n* fetched /home/user/a\n  commit: b85c140\n$ git fetch -v /home/user/a.git\n* fetched /home/user/a\n  commit: b85c140\n\nWhich one was fetched when? /home/user/a or /home/user/a.git?\nNo imagine you don't see the command (as if git fetch is called\nin some frontend). Would you be able to distinguish the sources?\n\nBesides, I just noticed git-clone is broken WRT the .git\nas well: I can clone a \"a.git\" into \"b\" (and it ignores -l and -s!),\nbut I can't fetch the \"a\" (aka \"origin\") being in \"b\". And of\ncourse, \"origin\" in \"b\" is setup as \"/path/a\", not \"/path/a.git\".\n"},{"id":"44144","messageId":"7vps495uvs.fsf@assigned-by-dhcp.cox.net","threadId":"8464","inReplyTo":"81b0412b0706060142h2df41f11pa0157a360831736@mail.gmail.com","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"J Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-06T08:50:47Z","receivedAt":"2007-06-06T08:50:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> On 6/6/07, Junio C Hamano <gitster@pobox.com> wrote:\n>> I suspect the above misses the point.\n>\n> Depends on the point. I mean to say: the path in the output\n> of the command does not exist anywhere.\n>\n>> The test \"ls /home/user/linux\" is not relevant.  Ability to say\n>> \"git fetch /home/user/linux\" is.\n>\n> This is still ambiguous:\n\nYup, there is an ambiguity.  Always has been.\n\n> Which one was fetched when? /home/user/a or /home/user/a.git?\n\nI am half tempted to say that this is very close to \"doctor, it\nconfuses me when I have both of them\".  Imagine the case where\nthe source were a remote repository _and_ there was no way other\nthan interacting with it via git protocol.  You cannot really\ntell (well, you can tell half, by trying both and if a worked\nbut a.git didn't you can tell that a.git does not exist) nor you\ndo not really care.\n\n> Besides, I just noticed git-clone is broken WRT the .git\n> as well: I can clone a \"a.git\" into \"b\" (and it ignores -l and -s!),\n> but I can't fetch the \"a\" (aka \"origin\") being in \"b\". And of\n> course, \"origin\" in \"b\" is setup as \"/path/a\", not \"/path/a.git\".\n\nThis probably is worth fixing, independent from what the message\nsays before or after your patch.\n"},{"id":"44160","messageId":"81b0412b0706060427l1846bde7racabcfea5d15bdb4@mail.gmail.com","threadId":"8464","inReplyTo":"7vps495uvs.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-06T11:27:57Z","receivedAt":"2007-06-06T11:27:57Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 6/6/07, J Junio C Hamano <gitster@pobox.com> wrote:\n> > Which one was fetched when? /home/user/a or /home/user/a.git?\n>\n> I am half tempted to say that this is very close to \"doctor, it\n> confuses me when I have both of them\".  Imagine the case where\n> the source were a remote repository _and_ there was no way other\n> than interacting with it via git protocol.  You cannot really\n> tell (well, you can tell half, by trying both and if a worked\n> but a.git didn't you can tell that a.git does not exist) nor you\n> do not really care.\n\nOf course you can! Just print the path to the remote EXACTLY\nhow the user entered it!\n\n> > Besides, I just noticed git-clone is broken WRT the .git\n> > as well: I can clone a \"a.git\" into \"b\" (and it ignores -l and -s!),\n> > but I can't fetch the \"a\" (aka \"origin\") being in \"b\". And of\n> > course, \"origin\" in \"b\" is setup as \"/path/a\", not \"/path/a.git\".\n>\n> This probably is worth fixing, independent from what the message\n> says before or after your patch.\n\nAnd \"probably\" means: it is broken, but this is ok?\n"},{"id":"44170","messageId":"81b0412b0706060852y4ab6b794m5fed0484c63159e4@mail.gmail.com","threadId":"8464","inReplyTo":"81b0412b0706060045k4098eb05tc596214f8d9673bf@mail.gmail.com","subject":"[PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-06T15:52:16Z","receivedAt":"2007-06-06T15:52:16Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Otherwise \".git\" is removed from every remote path which has it,\nincluding \"/some/path/somename.git\".\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nFixed truncation of \"/.git/\" (with a trailing slash).\nThe old code broke t5515, because it has left \"../.git/\"\nunchanged, but should have removed \".git/\".\n\n builtin-fetch--tool.c |   21 +++++++++++++++------\n 1 files changed, 15 insertions(+), 6 deletions(-)\n\n\nFrom c767dcc2000c72909013b9e97b18403686b44498 Mon Sep 17 00:00:00 2001\nFrom: Alex Riesen <raa@limbo.localdomain>\nDate: Wed, 6 Jun 2007 00:16:14 +0200\nSubject: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference\n\nOtherwise \".git\" is removed from every remote name which has it:\n\n  $ git fetch -v\n    * refs/heads/origin: same as branch 'master' of /home/user/linux\n      commit: 5ecd310\n  $ ls /home/user/linux\n  ls: /home/user/linux: No such file or directory\n  $ ls /home/user/linux.git\n  HEAD  objects  packed-refs  ...\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n builtin-fetch--tool.c |   21 +++++++++++++++------\n 1 files changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c\nindex ed4d5de..ec4a8c3 100644\n--- a/builtin-fetch--tool.c\n+++ b/builtin-fetch--tool.c\n@@ -140,7 +140,7 @@ static int append_fetch_head(FILE *fp,\n \t\t\t     int verbose, int force)\n {\n \tstruct commit *commit;\n-\tint remote_len, i, note_len;\n+\tint remote_len, note_len;\n \tunsigned char sha1[20];\n \tchar note[1024];\n \tconst char *what, *kind;\n@@ -173,11 +173,20 @@ static int append_fetch_head(FILE *fp,\n \t}\n \n \tremote_len = strlen(remote);\n-\tfor (i = remote_len - 1; remote[i] == '/' && 0 <= i; i--)\n-\t\t;\n-\tremote_len = i + 1;\n-\tif (4 < i && !strncmp(\".git\", remote + i - 3, 4))\n-\t\tremote_len = i - 3;\n+\tif (remote_len > 5) {\n+\t\tstatic const char ending[] = \"/.git\";\n+\t\tconst char *pe = ending + 4;\n+\t\tconst char *pr = remote + remote_len - 1;\n+\t\t/* ignore trailing slashes */\n+\t\twhile (pr > remote && *pr == '/')\n+\t\t\t--pr;\n+\t\tfor (; pr > remote && pe > ending; --pr, --pe)\n+\t\t\tif (*pr != *pe)\n+\t\t\t\tbreak;\n+\t\tif (pe == ending)\n+\t\t\t/* \"+ 1\" to leave the / before .git */\n+\t\t\tremote_len = pr - remote + 1;\n+\t}\n \n \tnote_len = 0;\n \tif (*what) {\n-- \n1.5.2.1.868.gb85c1\n\n"},{"id":"44183","messageId":"7vodjs3mrw.fsf@assigned-by-dhcp.cox.net","threadId":"8464","inReplyTo":"81b0412b0706060427l1846bde7racabcfea5d15bdb4@mail.gmail.com","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-06T19:28:51Z","receivedAt":"2007-06-06T19:28:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n>> > Besides, I just noticed git-clone is broken WRT the .git\n>> > as well: I can clone a \"a.git\" into \"b\" (and it ignores -l and -s!),\n>> > but I can't fetch the \"a\" (aka \"origin\") being in \"b\". And of\n>> > course, \"origin\" in \"b\" is setup as \"/path/a\", not \"/path/a.git\".\n>>\n>> This probably is worth fixing, independent from what the message\n>> says before or after your patch.\n>\n> And \"probably\" means: it is broken, but this is ok?\n\nNo; it means \"patches welcome\".  Regardless of the patch you are\npromoting, that would be a real fix.\n"},{"id":"44184","messageId":"7vfy543kzn.fsf@assigned-by-dhcp.cox.net","threadId":"8464","inReplyTo":"81b0412b0706060852y4ab6b794m5fed0484c63159e4@mail.gmail.com","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-06T20:07:24Z","receivedAt":"2007-06-06T20:07:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> Otherwise \".git\" is removed from every remote path which has it,\n> including \"/some/path/somename.git\".\n\nI was very tempted to apply this patch, but after re-reading it\nonce more, I decided to drop it.\n\nI do not mind keeping the extra .git/ suffix in the -v output in\nyour example, as the message is just \"verbose information\":\n\n  $ git fetch -v\n    * refs/heads/origin: same as branch 'master' of /home/user/linux\n      commit: 5ecd310\n\nBut the same output is used by log messages for the merge\ncommits; indeed, the primary purpose of this output is to\nprepare messages for merge commits.  From the beginning we\ndeliberately omitted .git suffix to keep the resulting log\nmessage short and sweet.  Keeping .git suffix goes against it.\n\nA repository \"git://$site/repo.git\" can be accessed with\n\"git://$site/repo\".  Repository owners _can_ confuse their users\nby having both repo and repo.git, but I honestly do not see a\nreason to encourage that.\n\nEarlier you mentioned you know of a case where \"$URL/repo.git\"\nexists and \"$URL/repo\" does not, and the current clone fails to\nset up the target repository after cloning from \"$URL/repo\"\ncorrectly?  I admit I haven't reproduced nor debugged it, but if\nthat is the case that needs to be fixed.\n"},{"id":"44205","messageId":"20070606224841.GA3969@steel.home","threadId":"8464","inReplyTo":"7vfy543kzn.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Fix the remote note the fetch-tool prints after storing a fetched reference","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-06T22:48:41Z","receivedAt":"2007-06-06T22:48:41Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Junio C Hamano, Wed, Jun 06, 2007 22:07:24 +0200:\n> \"Alex Riesen\" <raa.lkml@gmail.com> writes:\n> \n> > Otherwise \".git\" is removed from every remote path which has it,\n> > including \"/some/path/somename.git\".\n> \n> I was very tempted to apply this patch, but after re-reading it\n> once more, I decided to drop it.\n> \n> I do not mind keeping the extra .git/ suffix in the -v output in\n> your example, as the message is just \"verbose information\":\n> \n>   $ git fetch -v\n>     * refs/heads/origin: same as branch 'master' of /home/user/linux\n>       commit: 5ecd310\n> \n> But the same output is used by log messages for the merge\n> commits; indeed, the primary purpose of this output is to\n> prepare messages for merge commits.\n\nBTW, this is hard to believe. Were does git-merge call fetch--tool?\nNor have I found its use for logging purposes. Or, if you refer to the\nlogs a user can create by redirecting output of git fetch someplace,\nthan it is highly suspicious for tham to contain something short,\nsweet and not existing.\n\n> From the beginning we deliberately omitted .git suffix to keep the\n> resulting log message short and sweet.  Keeping .git suffix goes\n> against it.\n\nBut this is how the repo is actually named! If you want to keep the\n_message_ short and sweet than cut the suffix in the message\ngeneration code.\n\n> A repository \"git://$site/repo.git\" can be accessed with\n> \"git://$site/repo\".  Repository owners _can_ confuse their users\n> by having both repo and repo.git, but I honestly do not see a\n> reason to encourage that.\n\nPeople will never know whether they are encouraged or discouraged.\nThey just wont notice it is _wrong_ until they copy-paste the path\nfrom git-fetch output and do something nasty to it.\n\n> Earlier you mentioned you know of a case where \"$URL/repo.git\"\n> exists and \"$URL/repo\" does not, and the current clone fails to\n> set up the target repository after cloning from \"$URL/repo\"\n> correctly?  I admit I haven't reproduced nor debugged it, but if\n> that is the case that needs to be fixed.\n\n    mkdir a.git && cd a.git && git init && :>file && \\\n    git add . && git commit -m1 && mv .git/* . && rmdir .git && \\\n    cd .. && git clone -l -s a b && cd b && git fetch\n\nThe cloned repo \"b\" gets \"a\" verbatim, instead of something more\nuseful (like \"../../a.git\" or \"/full/path/a.git\". It is not even\n\"/full/path/a\").\n\ngit clone works correctly (origin's url is an absolute path) if a.git\nis given:\n\n    mkdir a.git && cd a.git && git init && :>file && \\\n    git add . && git commit -m1 && mv .git/* . && rmdir .git && \\\n    cd .. && git clone -l -s a.git b && cd b && git fetch\n\nFix, needed because of all this \"detachable suffix\" confusion:\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex fdd354f..d45618d 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -20,7 +20,7 @@ usage() {\n get_repo_base() {\n \t(\n \t\tcd \"`/bin/pwd`\" &&\n-\t\tcd \"$1\" &&\n+\t\tcd \"$1\" || cd \"$1.git\" &&\n \t\t{\n \t\t\tcd .git\n \t\t\tpwd\n"}]}