{"thread":{"id":"11735","subject":"[PATCH] Add support for host aliases in config files","startedAt":"2008-01-25T18:39:03Z","lastAt":"2008-01-25T21:51:42Z","messageCount":10,"participants":["Daniel Barkalow","Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"66583","messageId":"alpine.LNX.1.00.0801251336080.13593@iabervon.org","threadId":"11735","inReplyTo":null,"subject":"[PATCH] Add support for host aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-01-25T18:39:03Z","receivedAt":"2008-01-25T18:39:03Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"This allows users with different preferences for access methods to the\nsame remote repositories to rewrite each other's URLs to get the\ndesired access.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n Documentation/config.txt |   15 ++++++\n remote.c                 |  112 ++++++++++++++++++++++++++++++++++++++++++++-\n 2 files changed, 124 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 877eda9..dae79ce 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -596,6 +596,21 @@ help.format::\n \tValues 'man', 'info', 'web' and 'html' are supported. 'man' is\n \tthe default. 'web' and 'html' are the same.\n \n+host.<name>.base::\n+\tThe base URL which should be used for this particular\n+\thost. This can be used by a user who has a better access\n+\tmethod to a repository than other users to make use of the\n+\tpreferable path despite getting URLs from other users using\n+\tmore commonly-available methods. Alternatively, a user who\n+\tonly has less privileged access to a repository than the usual\n+\taudience can use this mechanism to replace disallowed methods\n+\twith public ones.\n+\n+host.<name>.alias::\n+\tAdditional base URLs which refer to this host. If a URL\n+\tmatches this, any access to it will use the URL formed with\n+\tthe corresponding base URL instead of the given URL.\n+\n http.proxy::\n \tOverride the HTTP proxy, normally configured using the 'http_proxy'\n \tenvironment variable (see linkgit:curl[1]).  This can be overridden\ndiff --git a/remote.c b/remote.c\nindex 0e00680..76ed576 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2,6 +2,15 @@\n #include \"remote.h\"\n #include \"refs.h\"\n \n+struct host {\n+\tconst char *name;\n+\n+\tconst char *base;\n+\n+\tconst char **alias;\n+\tint alias_nr;\n+};\n+\n static struct remote **remotes;\n static int allocated_remotes;\n \n@@ -11,9 +20,32 @@ static int allocated_branches;\n static struct branch *current_branch;\n static const char *default_remote_name;\n \n+static struct host **hosts;\n+static int allocated_hosts;\n+\n #define BUF_SIZE (2048)\n static char buffer[BUF_SIZE];\n \n+static const char *alias_url(const char *url)\n+{\n+\tint i, j;\n+\tfor (i = 0; i < allocated_hosts; i++) {\n+\t\tif (!hosts[i])\n+\t\t\tcontinue;\n+\t\tfor (j = 0; j < hosts[i]->alias_nr; j++) {\n+\t\t\tif (!prefixcmp(url, hosts[i]->alias[j])) {\n+\t\t\t\tchar *ret = malloc(strlen(hosts[i]->base) -\n+\t\t\t\t\t\t   strlen(hosts[i]->alias[j]) +\n+\t\t\t\t\t\t   strlen(url) + 1);\n+\t\t\t\tstrcpy(ret, hosts[i]->base);\n+\t\t\t\tstrcat(ret, url + strlen(hosts[i]->alias[j]));\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\t}\n+\treturn url;\n+}\n+\n static void add_push_refspec(struct remote *remote, const char *ref)\n {\n \tint nr = remote->push_refspec_nr + 1;\n@@ -41,6 +73,11 @@ static void add_url(struct remote *remote, const char *url)\n \tremote->url_nr = nr;\n }\n \n+static void add_url_alias(struct remote *remote, const char *url)\n+{\n+\tadd_url(remote, alias_url(url));\n+}\n+\n static struct remote *make_remote(const char *name, int len)\n {\n \tint i, empty = -1;\n@@ -121,6 +158,48 @@ static struct branch *make_branch(const char *name, int len)\n \treturn branches[empty];\n }\n \n+static struct host *make_host(const char *name, int len)\n+{\n+\tint i, empty = -1;\n+\n+\tfor (i = 0; i < allocated_hosts; i++) {\n+\t\tif (!hosts[i]) {\n+\t\t\tif (empty < 0)\n+\t\t\t\tempty = i;\n+\t\t} else {\n+\t\t\tif (len ? (!strncmp(name, hosts[i]->name, len) &&\n+\t\t\t\t   !hosts[i]->name[len]) :\n+\t\t\t    !strcmp(name, hosts[i]->name))\n+\t\t\t\treturn hosts[i];\n+\t\t}\n+\t}\n+\n+\tif (empty < 0) {\n+\t\tempty = allocated_hosts;\n+\t\tallocated_hosts += allocated_hosts ? allocated_hosts : 1;\n+\t\thosts = xrealloc(hosts,\n+\t\t\t\t sizeof(*hosts) * allocated_hosts);\n+\t\tmemset(hosts + empty, 0,\n+\t\t       (allocated_hosts - empty) * sizeof(*hosts));\n+\t}\n+\thosts[empty] = xcalloc(1, sizeof(struct host));\n+\tif (len)\n+\t\thosts[empty]->name = xstrndup(name, len);\n+\telse\n+\t\thosts[empty]->name = xstrdup(name);\n+\n+\treturn hosts[empty];\n+}\n+\n+static void add_alias(struct host *host, const char *name)\n+{\n+\tint nr = host->alias_nr + 1;\n+\thost->alias =\n+\t\txrealloc(host->alias, nr * sizeof(char *));\n+\thost->alias[nr-1] = name;\n+\thost->alias_nr = nr;\n+}\n+\n static void read_remotes_file(struct remote *remote)\n {\n \tFILE *f = fopen(git_path(\"remotes/%s\", remote->name), \"r\");\n@@ -154,7 +233,7 @@ static void read_remotes_file(struct remote *remote)\n \n \t\tswitch (value_list) {\n \t\tcase 0:\n-\t\t\tadd_url(remote, xstrdup(s));\n+\t\t\tadd_url_alias(remote, xstrdup(s));\n \t\t\tbreak;\n \t\tcase 1:\n \t\t\tadd_push_refspec(remote, xstrdup(s));\n@@ -206,7 +285,7 @@ static void read_branches_file(struct remote *remote)\n \t} else {\n \t\tbranch = \"refs/heads/master\";\n \t}\n-\tadd_url(remote, p);\n+\tadd_url_alias(remote, p);\n \tadd_fetch_refspec(remote, branch);\n \tremote->fetch_tags = 1; /* always auto-follow */\n }\n@@ -233,6 +312,20 @@ static int handle_config(const char *key, const char *value)\n \t\t\tadd_merge(branch, xstrdup(value));\n \t\treturn 0;\n \t}\n+\tif (!prefixcmp(key, \"host.\")) {\n+\t\tstruct host *host;\n+\t\tname = key + 5;\n+\t\tsubkey = strrchr(name, '.');\n+\t\tif (!subkey)\n+\t\t\treturn 0;\n+\t\thost = make_host(name, subkey - name);\n+\t\tif (!value)\n+\t\t\treturn 0;\n+\t\tif (!strcmp(subkey, \".base\"))\n+\t\t\thost->base = xstrdup(value);\n+\t        else if (!strcmp(subkey, \".alias\"))\n+\t\t\tadd_alias(host, xstrdup(value));\n+\t}\n \tif (prefixcmp(key,  \"remote.\"))\n \t\treturn 0;\n \tname = key + 7;\n@@ -284,6 +377,18 @@ static int handle_config(const char *key, const char *value)\n \treturn 0;\n }\n \n+static void alias_all_urls(void)\n+{\n+\tint i, j;\n+\tfor (i = 0; i < allocated_remotes; i++) {\n+\t\tif (!remotes[i])\n+\t\t\tcontinue;\n+\t\tfor (j = 0; j < remotes[i]->url_nr; j++) {\n+\t\t\tremotes[i]->url[j] = alias_url(remotes[i]->url[j]);\n+\t\t}\n+\t}\n+}\n+\n static void read_config(void)\n {\n \tunsigned char sha1[20];\n@@ -300,6 +405,7 @@ static void read_config(void)\n \t\t\tmake_branch(head_ref + strlen(\"refs/heads/\"), 0);\n \t}\n \tgit_config(handle_config);\n+\talias_all_urls();\n }\n \n struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)\n@@ -355,7 +461,7 @@ struct remote *remote_get(const char *name)\n \t\t\tread_branches_file(ret);\n \t}\n \tif (!ret->url)\n-\t\tadd_url(ret, name);\n+\t\tadd_url_alias(ret, name);\n \tif (!ret->url)\n \t\treturn NULL;\n \tret->fetch = parse_ref_spec(ret->fetch_refspec_nr, ret->fetch_refspec);\n-- \n1.5.4.rc3.4.g16335\n"},{"id":"66584","messageId":"m3fxwlagbu.fsf@localhost.localdomain","threadId":"11735","inReplyTo":"alpine.LNX.1.00.0801251336080.13593@iabervon.org","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-01-25T18:52:27Z","receivedAt":"2008-01-25T18:52:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> This allows users with different preferences for access methods to the\n> same remote repositories to rewrite each other's URLs to get the\n> desired access.\n\n[...]\n> +host.<name>.base::\n> +\tThe base URL which should be used for this particular\n> +\thost. This can be used by a user who has a better access\n> +\tmethod to a repository than other users to make use of the\n> +\tpreferable path despite getting URLs from other users using\n> +\tmore commonly-available methods. Alternatively, a user who\n> +\tonly has less privileged access to a repository than the usual\n> +\taudience can use this mechanism to replace disallowed methods\n> +\twith public ones.\n> +\n> +host.<name>.alias::\n> +\tAdditional base URLs which refer to this host. If a URL\n> +\tmatches this, any access to it will use the URL formed with\n> +\tthe corresponding base URL instead of the given URL.\n> +\n\n>From this I could not get how those configuration are meant to be\nused. Perhaps some usage example?\n\nBTW. wouldn't the same be solved better by enabling remote.<name>.url\nto be multi-valued, first working for fetch, all URLs for push?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"66585","messageId":"7vabmt7mrr.fsf@gitster.siamese.dyndns.org","threadId":"11735","inReplyTo":"m3fxwlagbu.fsf@localhost.localdomain","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-25T19:01:12Z","receivedAt":"2008-01-25T19:01:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> From this I could not get how those configuration are meant to be\n> used. Perhaps some usage example?\n>\n> BTW. wouldn't the same be solved better by enabling remote.<name>.url\n> to be multi-valued, first working for fetch, all URLs for push?\n\nI think that is already the case.  \"git-remote\" currently has an\nannoying bug I haven't bothered to look into that makes the\ncommand complain when remote.$nick.url has more than one values.\nWorse, it complains _twice_ (or N-1 times for a remote that has\nN URLs).\n\n        : gitster git.git/master; git remote\n        Warning: more than one remote.builders.url\n        Warning: more than one remote.builders.url\n        builders\n        gfi\n        git-gui\n        gitk\n        git-p4\n        git-svn\n        jbf-um\n        ko\n        ko-private\n        mingw\n        origin\n        repo\n        spearce.git\n        wing-fc5\n        wing-fc7\n        wing-fc8\n\nHere, \"builders\" remote has 3 URLs because I wanted to use it to\npush to 3 machines on which I build binary releases.\n"},{"id":"66587","messageId":"alpine.LNX.1.00.0801251355490.13593@iabervon.org","threadId":"11735","inReplyTo":"m3fxwlagbu.fsf@localhost.localdomain","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-01-25T19:09:30Z","receivedAt":"2008-01-25T19:09:30Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 25 Jan 2008, Jakub Narebski wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > This allows users with different preferences for access methods to the\n> > same remote repositories to rewrite each other's URLs to get the\n> > desired access.\n> \n> [...]\n> > +host.<name>.base::\n> > +\tThe base URL which should be used for this particular\n> > +\thost. This can be used by a user who has a better access\n> > +\tmethod to a repository than other users to make use of the\n> > +\tpreferable path despite getting URLs from other users using\n> > +\tmore commonly-available methods. Alternatively, a user who\n> > +\tonly has less privileged access to a repository than the usual\n> > +\taudience can use this mechanism to replace disallowed methods\n> > +\twith public ones.\n> > +\n> > +host.<name>.alias::\n> > +\tAdditional base URLs which refer to this host. If a URL\n> > +\tmatches this, any access to it will use the URL formed with\n> > +\tthe corresponding base URL instead of the given URL.\n> > +\n> \n> From this I could not get how those configuration are meant to be\n> used. Perhaps some usage example?\n\n[host \"kernel\"]\n        base = git://git.kernel.org/pub/\n        alias = git+ssh://master.kernel.org/pub/\n\talias = master.kernel.org:/pub/\n\n> BTW. wouldn't the same be solved better by enabling remote.<name>.url\n> to be multi-valued, first working for fetch, all URLs for push?\n\nThe real point is actually for when you're dealing with URLs on the \ncommand line which you've cut-and-paste from email or other things. For \nexample, the patches in the -mm quilt series say where the git trees are, \nbut they're all like \n\"git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\", \nwhich is ideal for people (like Andrew) who have accounts on master, but \nrequires manual fixing for people (like me) who don't.\n\nWith the above config, I can do:\n\ngit fetch git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\n\nand it actually fetches\n\ngit://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git, which \nactually works for me.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"66588","messageId":"200801252033.13142.jnareb@gmail.com","threadId":"11735","inReplyTo":"alpine.LNX.1.00.0801251355490.13593@iabervon.org","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-01-25T19:33:12Z","receivedAt":"2008-01-25T19:33:12Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Friday, 25 January 2008, Daniel Barkalow wrote:\n> On Fri, 25 Jan 2008, Jakub Narebski wrote:\n>> Daniel Barkalow <barkalow@iabervon.org> writes:\n>> \n>>> This allows users with different preferences for access methods to the\n>>> same remote repositories to rewrite each other's URLs to get the\n>>> desired access.\n>> \n>> [...]\n>>> +host.<name>.base::\n>>> +\tThe base URL which should be used for this particular\n>>> +\thost. This can be used by a user who has a better access\n>>> +\tmethod to a repository than other users to make use of the\n>>> +\tpreferable path despite getting URLs from other users using\n>>> +\tmore commonly-available methods. Alternatively, a user who\n>>> +\tonly has less privileged access to a repository than the usual\n>>> +\taudience can use this mechanism to replace disallowed methods\n>>> +\twith public ones.\n>>> +\n>>> +host.<name>.alias::\n>>> +\tAdditional base URLs which refer to this host. If a URL\n>>> +\tmatches this, any access to it will use the URL formed with\n>>> +\tthe corresponding base URL instead of the given URL.\n>>> +\n>> \n>> From this I could not get how those configuration are meant to be\n>> used. Perhaps some usage example?\n> \n> [host \"kernel\"]\n>         base = git://git.kernel.org/pub/\n>         alias = git+ssh://master.kernel.org/pub/\n>         alias = master.kernel.org:/pub/\n> \n>> BTW. wouldn't the same be solved better by enabling remote.<name>.url\n>> to be multi-valued, first working for fetch, all URLs for push?\n\nAh, thanks. I have misunderstood the above description (hint, hint!)...\n \n> The real point is actually for when you're dealing with URLs on the \n> command line which you've cut-and-paste from email or other things. For \n> example, the patches in the -mm quilt series say where the git trees are, \n> but they're all like \n> \"git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\", \n> which is ideal for people (like Andrew) who have accounts on master, but \n> requires manual fixing for people (like me) who don't.\n> \n> With the above config, I can do:\n> \n> git fetch git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\n\nCouldn't you just configure \"kernel\" remote, and use \"git fetch kernel\"\ninstead?\n\n> and it actually fetches\n> \n> git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\n>\n> which actually works for me.\n\nSo this config variable is actually about _rewriting_ URLs, rather than\nhaving multiple _alternate_ URLs to fetch from. IMHO either the\ndocumentation above should be (re)written better (there is time, as we\nare in feature freeze), or the example mentioned above should be added\n(but where?).\n\n-- \nJakub Narebski\nPoland\n"},{"id":"66589","messageId":"alpine.LNX.1.00.0801251436060.13593@iabervon.org","threadId":"11735","inReplyTo":"200801252033.13142.jnareb@gmail.com","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-01-25T19:53:34Z","receivedAt":"2008-01-25T19:53:34Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 25 Jan 2008, Jakub Narebski wrote:\n\n> On Friday, 25 January 2008, Daniel Barkalow wrote:\n> > On Fri, 25 Jan 2008, Jakub Narebski wrote:\n> >> Daniel Barkalow <barkalow@iabervon.org> writes:\n> >> \n> >>> This allows users with different preferences for access methods to the\n> >>> same remote repositories to rewrite each other's URLs to get the\n> >>> desired access.\n> >> \n> >> [...]\n> >>> +host.<name>.base::\n> >>> +\tThe base URL which should be used for this particular\n> >>> +\thost. This can be used by a user who has a better access\n> >>> +\tmethod to a repository than other users to make use of the\n> >>> +\tpreferable path despite getting URLs from other users using\n> >>> +\tmore commonly-available methods. Alternatively, a user who\n> >>> +\tonly has less privileged access to a repository than the usual\n> >>> +\taudience can use this mechanism to replace disallowed methods\n> >>> +\twith public ones.\n> >>> +\n> >>> +host.<name>.alias::\n> >>> +\tAdditional base URLs which refer to this host. If a URL\n> >>> +\tmatches this, any access to it will use the URL formed with\n> >>> +\tthe corresponding base URL instead of the given URL.\n> >>> +\n> >> \n> >> From this I could not get how those configuration are meant to be\n> >> used. Perhaps some usage example?\n> > \n> > [host \"kernel\"]\n> >         base = git://git.kernel.org/pub/\n> >         alias = git+ssh://master.kernel.org/pub/\n> >         alias = master.kernel.org:/pub/\n> > \n> >> BTW. wouldn't the same be solved better by enabling remote.<name>.url\n> >> to be multi-valued, first working for fetch, all URLs for push?\n> \n> Ah, thanks. I have misunderstood the above description (hint, hint!)...\n\nYup, that's why I need to talk it through. It made perfect sense to me, \nbut I'd had the problem in the first place and wrote the code...\n\n> > The real point is actually for when you're dealing with URLs on the \n> > command line which you've cut-and-paste from email or other things. For \n> > example, the patches in the -mm quilt series say where the git trees are, \n> > but they're all like \n> > \"git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\", \n> > which is ideal for people (like Andrew) who have accounts on master, but \n> > requires manual fixing for people (like me) who don't.\n> > \n> > With the above config, I can do:\n> > \n> > git fetch git+ssh://master.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\n> \n> Couldn't you just configure \"kernel\" remote, and use \"git fetch kernel\"\n> instead?\n\nNote the .../dtor/input.git at the end. There are another 50-odd different \nURLs in -mm that start git+ssh://master.kernel.org/pub/ where I have to \nuse git://git.kernel.org/pub/ instead, and it's not a fixed set.\n\n> > and it actually fetches\n> > \n> > git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git\n> >\n> > which actually works for me.\n> \n> So this config variable is actually about _rewriting_ URLs, rather than\n> having multiple _alternate_ URLs to fetch from. IMHO either the\n> documentation above should be (re)written better (there is time, as we\n> are in feature freeze), or the example mentioned above should be added\n> (but where?).\n\nMaybe we should have a \"host.<name>.*\" section that explains the \ncollection of configuration options as a group? Like:\n\n----------\nhost.<name>.*::\n\tThese options provide a way to rewrite URLs when there is a\n\tpattern of URLs with a common prefix which should be replaced\n\twith a different prefix. For every 'alias' prefix given, any\n\tURL git receives that starts with that prefix will be\n\trewritten to have the 'base' prefix instead. In cases where\n\tsome site serves a large number of repositories, and serves\n\tthem with multiple access methods, and some users need to use\n\tdifferent access methods, this feature allows people to\n\tspecify any of the equivalent URLs and have git automatically\n\trewrite the URL to the best alternative for the particular\n\tuser, even for a never-before-seen repository on the site.\n\nhost.<name>.base::\n\tThe base URL which should be used for this particular\n\thost.\n\nhost.<name>.alias::\n\tAdditional base URLs which refer to this host. If a URL\n\tmatches this, any access to it will use the URL formed with\n\tthe corresponding base URL instead of the given URL.\n----------\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"66594","messageId":"7vir1h64k7.fsf@gitster.siamese.dyndns.org","threadId":"11735","inReplyTo":"200801252033.13142.jnareb@gmail.com","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-01-25T20:19:52Z","receivedAt":"2008-01-25T20:19:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> So this config variable is actually about _rewriting_ URLs, rather than\n> having multiple _alternate_ URLs to fetch from. IMHO either the\n> documentation above should be (re)written better (there is time, as we\n> are in feature freeze), or the example mentioned above should be added\n> (but where?).\n\nI think Documentation/urls.txt would be a good candidate.\nCurrently it talks only about non-nicknamed remotes, and is\nincluded only in clone and remote.  This makes sense as their\nusage of urls.txt documentation is to talk about non-nicknamed\nforms only (obviously clone cannot talk about nicknames in a\nlocal repository that does not yet exist, and \"remote add\" needs\na non-nicknamed form as well).\n\nDocumentation/urls.txt can be enhanced to say that once you have\nthe remote.*.url and other configs, you can use its nickname to\nname a remote repository.  Then it would become a good enough\nshape to be included in push/fetch/pull pages as well.\n"},{"id":"66597","messageId":"alpine.LNX.1.00.0801251535380.13593@iabervon.org","threadId":"11735","inReplyTo":"7vir1h64k7.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-01-25T21:12:35Z","receivedAt":"2008-01-25T21:12:35Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 25 Jan 2008, Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > So this config variable is actually about _rewriting_ URLs, rather than\n> > having multiple _alternate_ URLs to fetch from. IMHO either the\n> > documentation above should be (re)written better (there is time, as we\n> > are in feature freeze), or the example mentioned above should be added\n> > (but where?).\n> \n> I think Documentation/urls.txt would be a good candidate.\n> Currently it talks only about non-nicknamed remotes, and is\n> included only in clone and remote.  This makes sense as their\n> usage of urls.txt documentation is to talk about non-nicknamed\n> forms only (obviously clone cannot talk about nicknames in a\n> local repository that does not yet exist, and \"remote add\" needs\n> a non-nicknamed form as well).\n> \n> Documentation/urls.txt can be enhanced to say that once you have\n> the remote.*.url and other configs, you can use its nickname to\n> name a remote repository.  Then it would become a good enough\n> shape to be included in push/fetch/pull pages as well.\n\nIsn't that Documentation/urls-remotes.txt?\n\nIn any case, this is a different nicknaming mechanism, because remotes are \nnicknames for repositories, and this is nicknames for collections of \nsimilarly-named repositories. (E.g., all the different publicly-accessible \nrepositories on kernel.org)\n\nSo, something like:\n\ndiff --git a/Documentation/urls.txt b/Documentation/urls.txt\nindex 81ac17f..f47b9e0 100644\n--- a/Documentation/urls.txt\n+++ b/Documentation/urls.txt\n@@ -36,6 +36,29 @@ To sync with a local directory, you can use:\n - file:///path/to/repo.git/\n ===============================================================\n \n+If there are a large number of similarly-named remote repositories and\n+you want to use a different format for them (such that the URLs you\n+use will be rewritten into URLs that work), you can create a\n+configuration section of the form:\n+\n+------------\n+\t[host \"<host>\"]\n+\t\tbase = <actual url base>\n+\t\talias = <other url base>\n+------------\n+\n+In particular, if you need to use URLs like\n+git://git.host.xz/repo.git, and you're getting a lot of URLs like\n+host.xz:/path/to/repo.git/, or you'd like to use a URL like\n+\"work:repo.git\" you can use a section:\n+\n+------------\n+\t[host \"host.xz\"]\n+\t\tbase = git://git.host.xz/\n+\t\talias = host.xz:/path/to/\n+\t\talias = work:\n+------------\n+\n ifndef::git-clone[]\n They are mostly equivalent, except when cloning.  See\n linkgit:git-clone[1] for details.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"66599","messageId":"200801252248.12682.jnareb@gmail.com","threadId":"11735","inReplyTo":"alpine.LNX.1.00.0801251535380.13593@iabervon.org","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-01-25T21:48:11Z","receivedAt":"2008-01-25T21:48:11Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Daniel Barkalow wrote:\n\n> So, something like:\n> \n> diff --git a/Documentation/urls.txt b/Documentation/urls.txt\n> index 81ac17f..f47b9e0 100644\n> --- a/Documentation/urls.txt\n> +++ b/Documentation/urls.txt\n> @@ -36,6 +36,29 @@ To sync with a local directory, you can use:\n>  - file:///path/to/repo.git/\n>  ===============================================================\n>  \n> +If there are a large number of similarly-named remote repositories and\n> +you want to use a different format for them (such that the URLs you\n> +use will be rewritten into URLs that work), you can create a\n> +configuration section of the form:\n> +\n> +------------\n> +\t[host \"<host>\"]\n> +\t\tbase = <actual url base>\n> +\t\talias = <other url base>\n> +------------\n> +\n> +In particular, if you need to use URLs like\n> +git://git.host.xz/repo.git, and you're getting a lot of URLs like\n> +host.xz:/path/to/repo.git/, or you'd like to use a URL like\n> +\"work:repo.git\" you can use a section:\n> +\n> +------------\n> +\t[host \"host.xz\"]\n> +\t\tbase = git://git.host.xz/\n> +\t\talias = host.xz:/path/to/\n> +\t\talias = work:\n> +------------\n> +\n\nCould you _finish_ that documentation with finished example of command\nline example, which gets its URL rewritten? It stops a bit suddenly.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"66600","messageId":"200801252251.42760.jnareb@gmail.com","threadId":"11735","inReplyTo":"alpine.LNX.1.00.0801251436060.13593@iabervon.org","subject":"Re: [PATCH] Add support for host aliases in config files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-01-25T21:51:42Z","receivedAt":"2008-01-25T21:51:42Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Fri, 25 Jan 2008, Daniel Barkalow wrote:\n> On Fri, 25 Jan 2008, Jakub Narebski wrote:\n> \n>>\n>> So this config variable is actually about _rewriting_ URLs, rather than\n>> having multiple _alternate_ URLs to fetch from. IMHO either the\n>> documentation above should be (re)written better (there is time, as we\n>> are in feature freeze), or the example mentioned above should be added\n>> (but where?).\n> \n> Maybe we should have a \"host.<name>.*\" section that explains the \n> collection of configuration options as a group? Like:\n> \n> ----------\n> host.<name>.*::\n> \tThese options provide a way to rewrite URLs when there is a\n> \tpattern of URLs with a common prefix which should be replaced\n> \twith a different prefix. For every 'alias' prefix given, any\n> \tURL git receives that starts with that prefix will be\n> \trewritten to have the 'base' prefix instead. In cases where\n> \tsome site serves a large number of repositories, and serves\n> \tthem with multiple access methods, and some users need to use\n> \tdifferent access methods, this feature allows people to\n> \tspecify any of the equivalent URLs and have git automatically\n> \trewrite the URL to the best alternative for the particular\n> \tuser, even for a never-before-seen repository on the site.\n> \n> host.<name>.base::\n> \tThe base URL which should be used for this particular\n> \thost.\n> \n> host.<name>.alias::\n> \tAdditional base URLs which refer to this host. If a URL\n> \tmatches this, any access to it will use the URL formed with\n> \tthe corresponding base URL instead of the given URL.\n\nGood idea. IMVHO it reads better than previous version. Together with\nexplanation and example usage in Documentation/urls.txt (or somewhere\nelse) it would be enough and easy to understand.\n\nBTW. shouldn't it be rather host.<name>.rewritebase (a la mod_rewrite)?\nI think it is better name for this configuration variable.\n\n-- \nJakub Narebski\nPoland\n"}]}