{"thread":{"id":"24603","subject":"URL substitution and config file precedence","startedAt":"2010-08-02T15:37:20Z","lastAt":"2010-08-02T20:57:48Z","messageCount":5,"participants":["martin f krafft","Ævar Arnfjörð Bjarmason","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"146949","messageId":"20100802153720.GA28481@fishbowl.rw.madduck.net","threadId":"24603","inReplyTo":null,"subject":"URL substitution and config file precedence","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-08-02T15:37:20Z","receivedAt":"2010-08-02T15:37:20Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"Dear Gits,\n\nI expect .git/config to tae precedence over ~/.gitconfig, which in\nturn gets favoured over /etc/gitconfig. This works fine, except for\nthe url.….insteadOf settings.\n\nHave a look at the following:\n\n  % grep madduck: .git/config\n    url = madduck:pub/puppet/modules/git\n\n  % grep -B1 nsteadOf /etc/gitconfig ~/.gitconfig\n  /etc/gitconfig-[url \"git://git.madduck.net/madduck/\"]\n  /etc/gitconfig: insteadOf = madduck:\n  --\n  /home/madduck/.gitconfig-[url \"ssh://git.madduck.net/madduck/\"]\n  /home/madduck/.gitconfig:       insteadOf = madduck:\n  /home/madduck/.gitconfig:       pushInsteadOf = git://git.madduck.net/madduck/\n\n  % git push -v\n  Pushing to git://git.madduck.net/madduck/pub/puppet/modules/git\n  fatal: The remote end hung up unexpectedly\n\nThere seem to be two problems:\n\n  1. the value from /etc/gitconfig seems to be preferred over the\n     one from ~/.gitconfig. I think this is due to the fact that the\n     syntax for URL substitution is a bit whack and the two keys\n     different, so the merge is actually a union-merge, and then the\n     result is probably just the first match (git:// sorts before\n     ssh://).\n\n  2. URL substitution is not recursive, or else the git:// URL would\n     eventually be replaced with the ssh:// URL.\n\nI can address both issues by adding a \"pushInsteadOf = madduck:\" to\n~/.gitconfig, but …\n\n… that only addresses pushing. I don't see a way to fix fetching,\nwhere the pushInsteadOf trick does not work.\n\nAny ideas how to work around it?\n\nWhy was the syntax chosen backwards in this way? Why not have\n\n  [urlsubst \"madduck:\"]\n      replaceWith = ssh://git.madduck.net/madduck/\n\nor even better:\n\n  [url_regsubst]\n      somefreelychosenname = s|madduck:|ssh://git.madduck.net/madduck/|\n\nThoughts?\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \n\"stab it and steer\"\n                                                             -- sailor\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"146952","messageId":"AANLkTikdyNjcgZpY=BPjkieacDXHPvp0he77VJZCMLpw@mail.gmail.com","threadId":"24603","inReplyTo":"20100802153720.GA28481@fishbowl.rw.madduck.net","subject":"Re: URL substitution and config file precedence","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-02T16:05:34Z","receivedAt":"2010-08-02T16:05:34Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Aug 2, 2010 at 15:37, martin f krafft <madduck@madduck.net> wrote:\n> Dear Gits,\n>\n> I expect .git/config to tae precedence over ~/.gitconfig, which in\n> turn gets favoured over /etc/gitconfig. This works fine, except for\n> the url.….insteadOf settings.\n>\n> Have a look at the following:\n>\n>  % grep madduck: .git/config\n>    url = madduck:pub/puppet/modules/git\n>\n>  % grep -B1 nsteadOf /etc/gitconfig ~/.gitconfig\n>  /etc/gitconfig-[url \"git://git.madduck.net/madduck/\"]\n>  /etc/gitconfig: insteadOf = madduck:\n>  --\n>  /home/madduck/.gitconfig-[url \"ssh://git.madduck.net/madduck/\"]\n>  /home/madduck/.gitconfig:       insteadOf = madduck:\n>  /home/madduck/.gitconfig:       pushInsteadOf = git://git.madduck.net/madduck/\n>\n>  % git push -v\n>  Pushing to git://git.madduck.net/madduck/pub/puppet/modules/git\n>  fatal: The remote end hung up unexpectedly\n>\n> There seem to be two problems:\n>\n>  1. the value from /etc/gitconfig seems to be preferred over the\n>     one from ~/.gitconfig. I think this is due to the fact that the\n>     syntax for URL substitution is a bit whack and the two keys\n>     different, so the merge is actually a union-merge, and then the\n>     result is probably just the first match (git:// sorts before\n>     ssh://).\n\nRight, the git-config backend just merges on a key-value basis. It isn't smart.\n\n> Why was the syntax chosen backwards in this way? Why not have\n>\n>  [urlsubst \"madduck:\"]\n>      replaceWith = ssh://git.madduck.net/madduck/\n>\n> or even better:\n>\n>  [url_regsubst]\n>      somefreelychosenname = s|madduck:|ssh://git.madduck.net/madduck/|\n\nI don't know, but it usually helps if you add the person who added the\nfeature to the CC-list.\n"},{"id":"146961","messageId":"20100802173853.GB5325@fishbowl.rw.madduck.net","threadId":"24603","inReplyTo":"AANLkTikdyNjcgZpY=BPjkieacDXHPvp0he77VJZCMLpw@mail.gmail.com","subject":"Re: URL substitution and config file precedence","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-08-02T17:38:53Z","receivedAt":"2010-08-02T17:38:53Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Ævar Arnfjörð Bjarmason <avarab@gmail.com> [2010.08.02.1805 +0200]:\n> I don't know, but it usually helps if you add the person who added\n> the feature to the CC-list.\n\nYeah, I didn't check. Does anyone happen to know who that was,\nsaving me the excursion into the history? I don't have Git cloned on\nthis laptop and I am on a really bad link. :(\n\nThanks,\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \n\"da haben wir es also: eine kirchliche ordnung mit priesterschaft,\n theologie, kultus, sakrament;\n kurz, alles das, was jesus von nazareth bekämpft hatte...\"\n                                                 - friedrich nietzsche\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"146962","messageId":"AANLkTimf+T9_W4oMjj+vujr+oDXwEuNO4OyjO+oRtV05@mail.gmail.com","threadId":"24603","inReplyTo":"20100802173853.GB5325@fishbowl.rw.madduck.net","subject":"Re: URL substitution and config file precedence","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-02T17:46:24Z","receivedAt":"2010-08-02T17:46:24Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Aug 2, 2010 at 17:38, martin f krafft <madduck@madduck.net> wrote:\n> also sprach Ævar Arnfjörð Bjarmason <avarab@gmail.com> [2010.08.02.1805 +0200]:\n>> I don't know, but it usually helps if you add the person who added\n>> the feature to the CC-list.\n>\n> Yeah, I didn't check. Does anyone happen to know who that was,\n> saving me the excursion into the history? I don't have Git cloned on\n> this laptop and I am on a really bad link. :(\n\nDaniel Barkalow added it back in 2008. Adding him to the CC list.\n"},{"id":"146990","messageId":"20100802205748.GA2890@burratino","threadId":"24603","inReplyTo":"20100802153720.GA28481@fishbowl.rw.madduck.net","subject":"Re: URL substitution and config file precedence","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-02T20:57:48Z","receivedAt":"2010-08-02T20:57:48Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"martin f krafft wrote:\n\n>   % grep madduck: .git/config\n>     url = madduck:pub/puppet/modules/git\n> \n>   % grep -B1 nsteadOf /etc/gitconfig ~/.gitconfig\n>   /etc/gitconfig-[url \"git://git.madduck.net/madduck/\"]\n>   /etc/gitconfig: insteadOf = madduck:\n>   --\n>   /home/madduck/.gitconfig-[url \"ssh://git.madduck.net/madduck/\"]\n>   /home/madduck/.gitconfig:       insteadOf = madduck:\n>   /home/madduck/.gitconfig:       pushInsteadOf = git://git.madduck.net/madduck/\n> \n>   % git push -v\n>   Pushing to git://git.madduck.net/madduck/pub/puppet/modules/git\n>   fatal: The remote end hung up unexpectedly\n> \n> There seem to be two problems:\n> \n>   1. the value from /etc/gitconfig seems to be preferred over the\n>      one from ~/.gitconfig. I think this is due to the fact that the\n>      syntax for URL substitution is a bit whack and the two keys\n>      different, so the merge is actually a union-merge, and then the\n>      result is probably just the first match (git:// sorts before\n>      ssh://).\n\nAlmost.  I do not think there is any sorting involved.\n\nIt instead seems to be an unintended consequence of the \"first match\nwins\" rule from v1.5.5-rc0~142^2 (url rewriting: take longest and\nfirst match, 2008-02-24).  If we were starting over, I think it would\nmake more sense to make the _last_ match win, which would be closer to\nhow git configuration works in general.\n\n> Why was the syntax chosen backwards in this way? Why not have\n> \n>   [urlsubst \"madduck:\"]\n>       replaceWith = ssh://git.madduck.net/madduck/\n\nI wasn’t there, so I can’t complain.\nhttp://thread.gmane.org/gmane.comp.version-control.git/74535/focus=74594\n\nI think you’re right, that\n\n\t[fakeurl \"madduck:\"]\n\t\turl = git://git.madduck.net/madduck/\n\t\tpushurl = ssh://git.madduck.net/madduck/\n\nor similar would be more convenient to work with than\n\n\t[url \"ssh://git.madduck.net/madduck/\"]\n\t\tpushinsteadof = madduck:\n\t[url \"git://git.madduck.net/madduck/\"]\n\t\tinsteadof = madduck:\n\nJonathan\n"}]}