{"thread":{"id":"42629","subject":"URL rewrite in local config unable to override global config rule","startedAt":"2016-06-16T10:14:25Z","lastAt":"2016-06-18T13:50:54Z","messageCount":6,"participants":["Saksham Saxena","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"289351","messageId":"CABYP2JZU5wqxCK1B7b_fDB0Lqz4-7a_Erb5dHKReZHQecxC8QQ@mail.gmail.com","threadId":"42629","inReplyTo":null,"subject":"URL rewrite in local config unable to override global config rule","fromName":"Saksham Saxena","fromEmail":"saksham.saxena.1994@ieee.org","sentAt":"2016-06-16T10:14:17Z","receivedAt":"2016-06-16T10:14:25Z","isPatch":false,"sender":{"key":"saksham.saxena.1994@ieee.org","avatar":null},"body":"Hello everyone\n\nI came across an anomaly in git recently, and would like to share it\nhere. Please suggest if this is a bug, or if my approach is wrong.\n\nSummary : Added a new rule to the local config of a git repo by\nissuing ' git config --local url.\"https://\".insteadOf git:// ', but it\nwasn't observed by git as it kept using \"git://\".\n\nDetails : I had set my global config to use \"git://\" instead of\n\"https://\", as I prefer working with SSH. Recently, I began writing a\n'GitHub Wiki' of one of my GitHub projects, and, apparently, those\nWikis are normal git repositories, and can be cloned and edited\nlocally. However, the clone url available is served over HTTPS only,\nand doesn't support any other protocol. Naturally, I had to change my\nconfig to change the behavior of git while connecting to the remote. I\nthus proceeded to update the local config of the repo to use\n\"https://\" instead of \"git://\". However, my remote urls weren't\nupdated. I manually then removed these remote urls and added new HTTPS\nones. Yet, the remote urls showed \"git://\" protocol in them.\nScreenshot of the terminal window can be found here\n(http://i.stack.imgur.com/y7GMP.png).\n\nI tried to add the \"pushInsteadOf\" rule as well, but again, it didn't\ntake effect. This is particularly disappointing, because the local\nconfig have the highest priority, and yet it isn't effective at all.\nBecause of the limitation of my remote, I cannot even push my changes.\nTrue, that I can dig up some dirty workarounds, but I do not\nunderstand why this behavior is seen.\n\nI have also asked this on the popular Stack Overflow forum\n(http://stackoverflow.com/questions/37844460/git-remote-url-is-not-updating).\nIf any of the moderators here do not find this issue as a bug, then\nthey may help me out on the forum itself (if you happen to be on it)\nto reduce the noise on this thread.\n\nI hope I described my problem clearly. Awaiting response.\n\nRegards\nSaksham Saxena\n"},{"id":"289357","messageId":"20160616121353.GB15988@sigill.intra.peff.net","threadId":"42629","inReplyTo":"CABYP2JZU5wqxCK1B7b_fDB0Lqz4-7a_Erb5dHKReZHQecxC8QQ@mail.gmail.com","subject":"Re: URL rewrite in local config unable to override global config rule","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-06-16T12:13:54Z","receivedAt":"2016-06-16T12:14:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jun 16, 2016 at 03:44:17PM +0530, Saksham Saxena wrote:\n\n> Summary : Added a new rule to the local config of a git repo by\n> issuing ' git config --local url.\"https://\".insteadOf git:// ', but it\n> wasn't observed by git as it kept using \"git://\".\n\nHmm. This works in a simple example for me...\n\n> Details : I had set my global config to use \"git://\" instead of\n> \"https://\", as I prefer working with SSH.\n\n..even if I have an existing \"url.git://.insteadOf=https://\". But I\ncould believe that having other config confuses things. The\nurl-rewriting is not \"last one wins\", but rather that we try all of\nthem, and the longest match wins.\n\nCan you show us the output of \"git config --list\" on a repository that\nis having this problem, and then the command that you run and its\noutput?\n\n> Recently, I began writing a\n> 'GitHub Wiki' of one of my GitHub projects, and, apparently, those\n> Wikis are normal git repositories, and can be cloned and edited\n> locally. However, the clone url available is served over HTTPS only,\n> and doesn't support any other protocol.\n\nYou should be able to clone, fetch, or push wiki repositories using any\nof the normal protocols. So:\n\n  git@github.com:username/repo.wiki.git\n\nshould work. Likewise, git:// will work if the repository is public, but\nyou cannot push over it.\n\n-Peff\n"},{"id":"289444","messageId":"CABYP2JZ5nNHh_cRkgpRMkn7Qfs4zAjy+wfaputJ0CvZ-M4FW6w@mail.gmail.com","threadId":"42629","inReplyTo":"20160616121353.GB15988@sigill.intra.peff.net","subject":"Re: URL rewrite in local config unable to override global config rule","fromName":"Saksham Saxena","fromEmail":"saksham.saxena.1994@ieee.org","sentAt":"2016-06-17T14:35:47Z","receivedAt":"2016-06-17T14:35:54Z","isPatch":false,"sender":{"key":"saksham.saxena.1994@ieee.org","avatar":null},"body":"On Thu, Jun 16, 2016 at 5:43 PM, Jeff King <peff@peff.net> wrote:\n> On Thu, Jun 16, 2016 at 03:44:17PM +0530, Saksham Saxena wrote:\n>\n>> Summary : Added a new rule to the local config of a git repo by\n>> issuing ' git config --local url.\"https://\".insteadOf git:// ', but it\n>> wasn't observed by git as it kept using \"git://\".\n>\n> Hmm. This works in a simple example for me...\n>\n>> Details : I had set my global config to use \"git://\" instead of\n>> \"https://\", as I prefer working with SSH.\n>\n> ..even if I have an existing \"url.git://.insteadOf=https://\". But I\n> could believe that having other config confuses things. The\n> url-rewriting is not \"last one wins\", but rather that we try all of\n>\n> > them, and the longest match wins.\n\nLongest? Could you elaborate please?\n\n>\n> Can you show us the output of \"git config --list\" on a repository that\n> is having this problem, and then the command that you run and its\n>\n> > output?\n\nHere you go (https://gist.github.com/sakshamsaxena/a1cee9c39ddc127ae659e92d02d58f0b).\nThe commands are run in that sequence.\n\n>\n>> Recently, I began writing a\n>> 'GitHub Wiki' of one of my GitHub projects, and, apparently, those\n>> Wikis are normal git repositories, and can be cloned and edited\n>> locally. However, the clone url available is served over HTTPS only,\n>> and doesn't support any other protocol.\n>\n> You should be able to clone, fetch, or push wiki repositories using any\n> of the normal protocols. So:\n>\n>   git@github.com:username/repo.wiki.git\n>\n> should work. Likewise, git:// will work if the repository is public, but\n>\n> > you cannot push over it.\n\nTrue. Can't push over git:// and that's why I'm limited to https://\n\n>\n> -Peff\n\n\n\n-- \nRegards\nSaksham Saxena\nMember, IEEE Delhi Section Student Network\nMember, IEEE DTU Student Branch\nStudent, Delhi Technological University\n"},{"id":"289445","messageId":"20160617150137.GA9197@sigill.intra.peff.net","threadId":"42629","inReplyTo":"CABYP2JZ5nNHh_cRkgpRMkn7Qfs4zAjy+wfaputJ0CvZ-M4FW6w@mail.gmail.com","subject":"Re: URL rewrite in local config unable to override global config rule","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-06-17T15:01:38Z","receivedAt":"2016-06-17T15:01:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 17, 2016 at 08:05:47PM +0530, Saksham Saxena wrote:\n\n> > ..even if I have an existing \"url.git://.insteadOf=https://\". But I\n> > could believe that having other config confuses things. The\n> > url-rewriting is not \"last one wins\", but rather that we try all of\n> >\n> > > them, and the longest match wins.\n> \n> Longest? Could you elaborate please?\n\nThe one that matches the longest number of characters. So\n\"https://example.com\" is a preferred match over \"https://\".\n\nI don't think that's what's going on here, though.\n\n> Here you go (https://gist.github.com/sakshamsaxena/a1cee9c39ddc127ae659e92d02d58f0b).\n> The commands are run in that sequence.\n\nOK, so you have:\n\n  url.git://.insteadof=https://\n\nin your initial config, to convert https URLs to git.\n\nLater you add:\n\n  url.https://.insteadof=git://\n\nto do the opposite.\n\nThe URL in your config uses http:\n\n  remote.origin.url=https://github.com/sakshamsaxena/sails-hook-jbvcs.wiki.git\n\nAnd when you push, this gets converted to \"git://\".\n\nI think this is the expected behavior, due to the first insteadOf, which\nconverts https to git. Both rules are \"active\", in the sense that the\nlater one does not replace the former; together they make a list of\nrules to try applying.\n\nGit doesn't recursively apply insteadOf transformations. So the \"convert\nhttps to git\" rule triggers, and we stop. The \"convert git to https\" one\ndoesn't trigger initially (because we are already https). And if we were\nto apply rules recursively in this case, it would loop infinitely.\n\nSo I this is all operating as intended. And what you really want is a\nway to say \"erase any earlier rewrite rules; I do not want them applied\nin this repository\". There's currently not any way to do that.\n\nFor other \"multi-valued configs\" like this one (i.e., ones that form a\nlist rather than overriding earlier values), we have started using the\nconvention that assigning the empty value resets the list. But this\nparticular config key has not learned that trick yet, so it would\nrequire a patch to git.\n\n> > You should be able to clone, fetch, or push wiki repositories using any\n> > of the normal protocols. So:\n> >\n> >   git@github.com:username/repo.wiki.git\n> >\n> > should work. Likewise, git:// will work if the repository is public, but\n> >\n> > > you cannot push over it.\n> \n> True. Can't push over git:// and that's why I'm limited to https://\n\nYou can over ssh, though (which I thought you said earlier was your\npreferred protocol).\n\n-Peff\n"},{"id":"289562","messageId":"CABYP2JZ7jek5kWqx+1CZQB0AQCngwtEYr2YJc6QiOMdGFMgUOw@mail.gmail.com","threadId":"42629","inReplyTo":"20160617150137.GA9197@sigill.intra.peff.net","subject":"Re: URL rewrite in local config unable to override global config rule","fromName":"Saksham Saxena","fromEmail":"saksham.saxena.1994@ieee.org","sentAt":"2016-06-18T05:36:41Z","receivedAt":"2016-06-18T05:36:46Z","isPatch":false,"sender":{"key":"saksham.saxena.1994@ieee.org","avatar":null},"body":"Thanks a lot Peff. This cleared a lot of things. Would it be okay if I\ncite some parts of this conversation on my personal blog?\n\nOn Fri, Jun 17, 2016 at 8:31 PM, Jeff King <peff@peff.net> wrote:\n> On Fri, Jun 17, 2016 at 08:05:47PM +0530, Saksham Saxena wrote:\n>\n>> > ..even if I have an existing \"url.git://.insteadOf=https://\". But I\n>> > could believe that having other config confuses things. The\n>> > url-rewriting is not \"last one wins\", but rather that we try all of\n>> >\n>> > > them, and the longest match wins.\n>>\n>> Longest? Could you elaborate please?\n>\n> The one that matches the longest number of characters. So\n> \"https://example.com\" is a preferred match over \"https://\".\n>\n> I don't think that's what's going on here, though.\n>\n>> Here you go (https://gist.github.com/sakshamsaxena/a1cee9c39ddc127ae659e92d02d58f0b).\n>> The commands are run in that sequence.\n>\n> OK, so you have:\n>\n>   url.git://.insteadof=https://\n>\n> in your initial config, to convert https URLs to git.\n>\n> Later you add:\n>\n>   url.https://.insteadof=git://\n>\n> to do the opposite.\n>\n> The URL in your config uses http:\n>\n>   remote.origin.url=https://github.com/sakshamsaxena/sails-hook-jbvcs.wiki.git\n>\n> And when you push, this gets converted to \"git://\".\n>\n> I think this is the expected behavior, due to the first insteadOf, which\n> converts https to git. Both rules are \"active\", in the sense that the\n> later one does not replace the former; together they make a list of\n> rules to try applying.\n>\n> Git doesn't recursively apply insteadOf transformations. So the \"convert\n> https to git\" rule triggers, and we stop. The \"convert git to https\" one\n> doesn't trigger initially (because we are already https). And if we were\n> to apply rules recursively in this case, it would loop infinitely.\n>\n> So I this is all operating as intended. And what you really want is a\n> way to say \"erase any earlier rewrite rules; I do not want them applied\n> in this repository\". There's currently not any way to do that.\n>\n> For other \"multi-valued configs\" like this one (i.e., ones that form a\n> list rather than overriding earlier values), we have started using the\n> convention that assigning the empty value resets the list. But this\n> particular config key has not learned that trick yet, so it would\n> require a patch to git.\n>\n>> > You should be able to clone, fetch, or push wiki repositories using any\n>> > of the normal protocols. So:\n>> >\n>> >   git@github.com:username/repo.wiki.git\n>> >\n>> > should work. Likewise, git:// will work if the repository is public, but\n>> >\n>> > > you cannot push over it.\n>>\n>> True. Can't push over git:// and that's why I'm limited to https://\n>\n> You can over ssh, though (which I thought you said earlier was your\n> preferred protocol).\n>\n> -Peff\n\nThanks and Regards\nSaksham Saxena\n"},{"id":"289577","messageId":"20160618134912.GA5616@sigill.intra.peff.net","threadId":"42629","inReplyTo":"CABYP2JZ7jek5kWqx+1CZQB0AQCngwtEYr2YJc6QiOMdGFMgUOw@mail.gmail.com","subject":"Re: URL rewrite in local config unable to override global config rule","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-06-18T13:49:12Z","receivedAt":"2016-06-18T13:50:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jun 18, 2016 at 11:06:41AM +0530, Saksham Saxena wrote:\n\n> Thanks a lot Peff. This cleared a lot of things. Would it be okay if I\n> cite some parts of this conversation on my personal blog?\n\nSure, that is fine with me.\n\n-Peff\n"}]}