{"thread":{"id":"33934","subject":"git clone does not understand insteadOf URLs","startedAt":"2013-05-25T20:23:44Z","lastAt":"2013-05-28T20:06:54Z","messageCount":10,"participants":["Gioele Barabucci","Elia Pinto","Andreas Schwab","John Keeping","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"218547","messageId":"51A11DD0.4040802@svario.it","threadId":"33934","inReplyTo":null,"subject":"git clone does not understand insteadOf URLs","fromName":"Gioele Barabucci","fromEmail":"gioele@svario.it","sentAt":"2013-05-25T20:23:44Z","receivedAt":"2013-05-25T20:23:44Z","isPatch":false,"sender":{"key":"gioele@svario.it","avatar":null},"body":"Hello,\n\nit seems that `git clone` does not understand keywords used `insteadOf` \nlonger URLs.\n\n     $ git clone remote-repo/ProjectA.git\n     fatal repository 'remote-repo/ProjectA.git' does not exist\n\nI suppose that git interprets the argument as a local directory. Git \nshould see if the argument matches one of the known URLs before raising \nan error.\n\nRegards,\n\n-- \nGioele Barabucci <gioele@svario.it>\n"},{"id":"218566","messageId":"CA+EOSB=ow9Vc2J8qb3GAp4xj2GgY8qes=5Q-k-rH6VsVLjzCsg@mail.gmail.com","threadId":"33934","inReplyTo":"51A11DD0.4040802@svario.it","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2013-05-26T15:13:26Z","receivedAt":"2013-05-26T15:13:26Z","isPatch":false,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"Why someone should be do something like this ? What is the use case ?\n\nBest regards\n\n2013/5/25, Gioele Barabucci <gioele@svario.it>:\n> Hello,\n>\n> it seems that `git clone` does not understand keywords used `insteadOf`\n> longer URLs.\n>\n>      $ git clone remote-repo/ProjectA.git\n>      fatal repository 'remote-repo/ProjectA.git' does not exist\n>\n> I suppose that git interprets the argument as a local directory. Git\n> should see if the argument matches one of the known URLs before raising\n> an error.\n>\n> Regards,\n>\n> --\n> Gioele Barabucci <gioele@svario.it>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n-- \nInviato dal mio dispositivo mobile\n"},{"id":"218570","messageId":"51A24C75.3090100@svario.it","threadId":"33934","inReplyTo":"CA+EOSB=ow9Vc2J8qb3GAp4xj2GgY8qes=5Q-k-rH6VsVLjzCsg@mail.gmail.com","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Gioele Barabucci","fromEmail":"gioele@svario.it","sentAt":"2013-05-26T17:55:01Z","receivedAt":"2013-05-26T17:55:01Z","isPatch":false,"sender":{"key":"gioele@svario.it","avatar":null},"body":"Il 26/05/2013 17:13, Elia Pinto ha scritto:\n >>       $ git clone remote-repo/ProjectA.git\n >>       fatal repository 'remote-repo/ProjectA.git' does not exist\n >\n> Why someone should be do something like this ? What is the use case ?\n\nSimple, I keep all my projects on the same server, so I would like to \nrefer to that server + path using 'remote-repo'.\n\n\"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n\nI also helps me when I move all the projects from one path to another in \nthe remote server: I only need to change the path once in `~/.gitconfig`.\n\nPlease note that `git remote add` correctly understands \n'remote-repo/ProjectA.git'. I was expecting that `clone` and `remote` \nboth used the same code to parse paths.\n\nRegards,\n\n-- \nGioele Barabucci <gioele@svario.it>\n"},{"id":"218571","messageId":"87a9nhhb9c.fsf@hase.home","threadId":"33934","inReplyTo":"51A24C75.3090100@svario.it","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2013-05-26T18:00:31Z","receivedAt":"2013-05-26T18:00:31Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Gioele Barabucci <gioele@svario.it> writes:\n\n> Simple, I keep all my projects on the same server, so I would like to\n> refer to that server + path using 'remote-repo'.\n>\n> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n\nYou can use \"remote-repo:\" instead.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"218573","messageId":"51A24FF4.4010102@svario.it","threadId":"33934","inReplyTo":"87a9nhhb9c.fsf@hase.home","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Gioele Barabucci","fromEmail":"gioele@svario.it","sentAt":"2013-05-26T18:09:56Z","receivedAt":"2013-05-26T18:09:56Z","isPatch":false,"sender":{"key":"gioele@svario.it","avatar":null},"body":"Il 26/05/2013 20:00, Andreas Schwab ha scritto:\n>> Simple, I keep all my projects on the same server, so I would like to\n>> refer to that server + path using 'remote-repo'.\n>>\n>> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n>\n> You can use \"remote-repo:\" instead.\n\nDo you mean I could use \n\"git+ssh://git.example.org//users/gioele/projects\" insteadOf \n\"remote-repo:\"? Yes, but now I have dozens of repositories already set \nup in various workstations and I do not want to go and change all of them.\n\nWhat really bugs me is the fact that `git clone` and `git remote add` \nparse the same path in different ways. Git already has many \ninconsistencies. This one can be easily ironed out.\n\nRegards,\n\n-- \nGioele Barabucci <gioele@svario.it>\n"},{"id":"218574","messageId":"20130526181430.GL27005@serenity.lan","threadId":"33934","inReplyTo":"51A24FF4.4010102@svario.it","subject":"Re: git clone does not understand insteadOf URLs","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-26T18:14:31Z","receivedAt":"2013-05-26T18:14:31Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Sun, May 26, 2013 at 08:09:56PM +0200, Gioele Barabucci wrote:\n> Il 26/05/2013 20:00, Andreas Schwab ha scritto:\n> >> Simple, I keep all my projects on the same server, so I would like to\n> >> refer to that server + path using 'remote-repo'.\n> >>\n> >> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n> >\n> > You can use \"remote-repo:\" instead.\n> \n> Do you mean I could use \n> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \n> \"remote-repo:\"? Yes, but now I have dozens of repositories already set \n> up in various workstations and I do not want to go and change all of them.\n> \n> What really bugs me is the fact that `git clone` and `git remote add` \n> parse the same path in different ways. Git already has many \n> inconsistencies. This one can be easily ironed out.\n\nIn what way do you think that `git remote add` handles the path?\n\nAll `git remote add` does is add a new \"remote.<name>.url\" entry to the\nconfiguration file with the value as given on the command line.  The\ninsteadOf mapping will only be applied when you try to fetch from/push\nto the remote.\n"},{"id":"218575","messageId":"51A252B9.7040008@svario.it","threadId":"33934","inReplyTo":"20130526181430.GL27005@serenity.lan","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Gioele Barabucci","fromEmail":"gioele@svario.it","sentAt":"2013-05-26T18:21:45Z","receivedAt":"2013-05-26T18:21:45Z","isPatch":false,"sender":{"key":"gioele@svario.it","avatar":null},"body":"Il 26/05/2013 20:14, John Keeping ha scritto:\n> On Sun, May 26, 2013 at 08:09:56PM +0200, Gioele Barabucci wrote:\n>> Il 26/05/2013 20:00, Andreas Schwab ha scritto:\n>>>> Simple, I keep all my projects on the same server, so I would like to\n>>>> refer to that server + path using 'remote-repo'.\n>>>>\n>>>> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n>\n> In what way do you think that `git remote add` handles the path?\n>\n> All `git remote add` does is add a new \"remote.<name>.url\" entry to the\n> configuration file with the value as given on the command line.  The\n> insteadOf mapping will only be applied when you try to fetch from/push\n> to the remote.\n\nRegardless of the implementation of the commands, if I do\n\n     mkdir projectA\n     cd projectA\n     git init .\n     git remote add origin remote-repo/projectA.git\n     git pull origin master\n\nI get a working repository. If I do\n\n     git clone remote-repo/projectA.git\n\nall I will get is an error.\n\nI do not see any reason (UX-wise) why the two sequences of commands \nshouldn't work the same when used on the same URL.\n\nRegards,\n\n-- \nGioele Barabucci <gioele@svario.it>\n"},{"id":"218576","messageId":"20130526190019.GM27005@serenity.lan","threadId":"33934","inReplyTo":"51A252B9.7040008@svario.it","subject":"Re: git clone does not understand insteadOf URLs","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-26T19:00:19Z","receivedAt":"2013-05-26T19:00:19Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Sun, May 26, 2013 at 08:21:45PM +0200, Gioele Barabucci wrote:\n> Il 26/05/2013 20:14, John Keeping ha scritto:\n> > On Sun, May 26, 2013 at 08:09:56PM +0200, Gioele Barabucci wrote:\n> >> Il 26/05/2013 20:00, Andreas Schwab ha scritto:\n> >>>> Simple, I keep all my projects on the same server, so I would like to\n> >>>> refer to that server + path using 'remote-repo'.\n> >>>>\n> >>>> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n> >\n> > In what way do you think that `git remote add` handles the path?\n> >\n> > All `git remote add` does is add a new \"remote.<name>.url\" entry to the\n> > configuration file with the value as given on the command line.  The\n> > insteadOf mapping will only be applied when you try to fetch from/push\n> > to the remote.\n> \n> Regardless of the implementation of the commands, if I do\n> \n>      mkdir projectA\n>      cd projectA\n>      git init .\n>      git remote add origin remote-repo/projectA.git\n>      git pull origin master\n> \n> I get a working repository. If I do\n> \n>      git clone remote-repo/projectA.git\n> \n> all I will get is an error.\n\nSo the problem is that \"git clone\" does not seem to perform normal\nremote processing if you give it something that looks like a path.\n\nMore specifically, it looks like the problem is that if you give clone\nsomething that does not contain a colon (':') it considers it to be a\nlocal path and dies if that path does not exist.  Adding a colon as\nAndreas suggested makes it look like a remote URL so it will be handled\ncorrectly.\n"},{"id":"218577","messageId":"51A25C77.6040205@svario.it","threadId":"33934","inReplyTo":"20130526190019.GM27005@serenity.lan","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Gioele Barabucci","fromEmail":"gioele@svario.it","sentAt":"2013-05-26T19:03:19Z","receivedAt":"2013-05-26T19:03:19Z","isPatch":false,"sender":{"key":"gioele@svario.it","avatar":null},"body":"Il 26/05/2013 21:00, John Keeping ha scritto:\n>> Regardless of the implementation of the commands, if I do\n>>\n>>       mkdir projectA\n>>       cd projectA\n>>       git init .\n>>       git remote add origin remote-repo/projectA.git\n>>       git pull origin master\n>>\n>> I get a working repository. If I do\n>>\n>>       git clone remote-repo/projectA.git\n>>\n>> all I will get is an error.\n>\n> So the problem is that \"git clone\" does not seem to perform normal\n> remote processing if you give it something that looks like a path.\n\nI understand the problem. In the original email that started this thread \nI asked for...\n\n> I suppose that git interprets the argument as a local directory. Git\n> should see if the argument matches one of the known URLs before\n> raising an error.\n\nI think all the paths should mean the same in every git command. In this \ncase, checking for insteadOf URLs before failing would solve this problem.\n\nRegards,\n\n-- \nGioele Barabucci <gioele@svario.it>\n"},{"id":"218698","messageId":"7v8v2yzx5t.fsf@alter.siamese.dyndns.org","threadId":"33934","inReplyTo":"87a9nhhb9c.fsf@hase.home","subject":"Re: git clone does not understand insteadOf URLs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-28T20:06:54Z","receivedAt":"2013-05-28T20:06:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Schwab <schwab@linux-m68k.org> writes:\n\n> Gioele Barabucci <gioele@svario.it> writes:\n>\n>> Simple, I keep all my projects on the same server, so I would like to\n>> refer to that server + path using 'remote-repo'.\n>>\n>> \"git+ssh://git.example.org//users/gioele/projects\" insteadOf \"remote-repo\"\n>\n> You can use \"remote-repo:\" instead.\n\nThat \"with colon\" is pretty much how it was designed to be used, but\nthe code did not insist that the insteadof has at least the scheme\npart, and by mistake allowed something like this\n\n\t[url \"k.org:/pub/scm/git\"] insteadOf = g\n\nto be used with \"g/foo\" to expand to \"k.org:/pub/scm/git/foo\".\n\nBut if \"git fetch g/foo\" with such a configuration happily goes to\n\"k.org:/pub/scm/git/foo\" without problems, then I think it is very\nreasonable to delay the \"is that a local filename?\" short-cut \"git\nclone\" does and let the insteadof URL expand take place before it.\n"}]}