{"thread":{"id":"12220","subject":"[PATCH 2/2] Add support for url aliases in config files","startedAt":"2008-02-20T18:43:53Z","lastAt":"2008-02-25T06:35:27Z","messageCount":22,"participants":["Daniel Barkalow","Junio C Hamano","Jay Soffian","しらいしななこ","Johannes Schindelin","Linus Torvalds","Jon Loeliger"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"69392","messageId":"alpine.LNX.1.00.0802201337060.19024@iabervon.org","threadId":"12220","inReplyTo":null,"subject":"[PATCH 2/2] Add support for url aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-20T18:43:53Z","receivedAt":"2008-02-20T18:43:53Z","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 by pattern\nmatching across a large set of similiarly set up repositories to each\nget the desired access.\n\nFor example, if you don't have a kernel.org account, you might want\nsettings like:\n\n[url \"git://git.kernel.org/pub/\"]\n      aka = master.kernel.org:/pub\n\nThen, if you give git a URL like:\n\n  master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git\n\nit will act like you gave it:\n\n  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git\n\nand you can cut-and-paste pull requests in email without fixing them\nby hand, for example.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\nThe previous version of [PATCH 1/2] doesn't need any changes.\n\nThis version has the replacement base in the key, as discussed, and makes \nthe whole thing about urls instead of hosts (so everything is renamed).\n\nI also added some tests, which are a little bit lame in the particular \ncontext of the test setup. Also, using git-config to set options with \ncomplicated keys is a bit awkward. Perhaps it should have support for a \ncommand line like:\n\ngit config --set remote \"This is my remote\" url http://example.com/repo\n\n Documentation/config.txt |   16 ++++++++\n Documentation/urls.txt   |   23 +++++++++++\n remote.c                 |   97 ++++++++++++++++++++++++++++++++++++++++++++-\n t/t5516-fetch-push.sh    |   31 +++++++++++++++\n 4 files changed, 164 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f2f6a77..44f4c4b 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -646,6 +646,11 @@ 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>.rewritebase::\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\n@@ -886,6 +891,17 @@ tar.umask::\n \tarchiving user's umask will be used instead.  See umask(2) and\n \tlinkgit:git-archive[1].\n \n+url.<base>.aka::\n+\tAny URL that starts with this value will be rewritten to\n+\tstart, instead, with <base>. In cases where some site serves a\n+\tlarge number of repositories, and serves them with multiple\n+\taccess methods, and some users need to use different access\n+\tmethods, this feature allows people to specify any of the\n+\tequivalent URLs and have git automatically rewrite the URL to\n+\tthe best alternative for the particular user, even for a\n+\tnever-before-seen repository on the site. The effect of\n+\thaving multiple aka values match is undefined.\n+\n user.email::\n \tYour email address to be recorded in any newly created commits.\n \tCan be overridden by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and\ndiff --git a/Documentation/urls.txt b/Documentation/urls.txt\nindex 81ac17f..0115af7 100644\n--- a/Documentation/urls.txt\n+++ b/Documentation/urls.txt\n@@ -44,3 +44,26 @@ endif::git-clone[]\n ifdef::git-clone[]\n They are equivalent, except the former implies --local option.\n endif::git-clone[]\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[url \"<actual url base>\"]\n+\t\taka = <other url base>\n+------------\n+\n+If you have a section:\n+\n+------------\n+\t[host \"git://git.host.xz/\"]\n+\t\taka = host.xz:/path/to/\n+\t\taka = work:\n+------------\n+\n+a URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\n+rewritten in any context that takes a URL to be\n+\"git://git.host.xz/repo.git\".\ndiff --git a/remote.c b/remote.c\nindex 457d8a4..f8ee38e 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2,6 +2,13 @@\n #include \"remote.h\"\n #include \"refs.h\"\n \n+struct rewrite {\n+\tconst char *base;\n+\tconst char **aka;\n+\tint aka_nr;\n+\tint aka_alloc;\n+};\n+\n static struct remote **remotes;\n static int remotes_alloc;\n static int remotes_nr;\n@@ -13,9 +20,33 @@ static int branches_nr;\n static struct branch *current_branch;\n static const char *default_remote_name;\n \n+static struct rewrite **rewrite;\n+static int rewrite_alloc;\n+static int rewrite_nr;\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 < rewrite_nr; i++) {\n+\t\tif (!rewrite[i])\n+\t\t\tcontinue;\n+\t\tfor (j = 0; j < rewrite[i]->aka_nr; j++) {\n+\t\t\tif (!prefixcmp(url, rewrite[i]->aka[j])) {\n+\t\t\t\tchar *ret = malloc(strlen(rewrite[i]->base) -\n+\t\t\t\t\t\t   strlen(rewrite[i]->aka[j]) +\n+\t\t\t\t\t\t   strlen(url) + 1);\n+\t\t\t\tstrcpy(ret, rewrite[i]->base);\n+\t\t\t\tstrcat(ret, url + strlen(rewrite[i]->aka[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 \tALLOC_GROW(remote->push_refspec,\n@@ -38,6 +69,11 @@ static void add_url(struct remote *remote, const char *url)\n \tremote->url[remote->url_nr++] = url;\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 \tstruct remote *ret;\n@@ -95,6 +131,35 @@ static struct branch *make_branch(const char *name, int len)\n \treturn ret;\n }\n \n+static struct rewrite *make_rewrite(const char *base, int len)\n+{\n+\tstruct rewrite *ret;\n+\tint i;\n+\n+\tfor (i = 0; i < rewrite_nr; i++) {\n+\t\tif (len ? (!strncmp(base, rewrite[i]->base, len) &&\n+\t\t\t   !rewrite[i]->base[len]) :\n+\t\t    !strcmp(base, rewrite[i]->base))\n+\t\t\treturn rewrite[i];\n+\t}\n+\n+\tALLOC_GROW(rewrite, rewrite_nr + 1, rewrite_alloc);\n+\tret = xcalloc(1, sizeof(struct rewrite));\n+\trewrite[rewrite_nr++] = ret;\n+\tif (len)\n+\t\tret->base = xstrndup(base, len);\n+\telse\n+\t\tret->base = xstrdup(base);\n+\n+\treturn ret;\n+}\n+\n+static void add_aka(struct rewrite *rewrite, const char *aka)\n+{\n+\tALLOC_GROW(rewrite->aka, rewrite->aka_nr + 1, rewrite->aka_alloc);\n+\trewrite->aka[rewrite->aka_nr++] = aka;\n+}\n+\n static void read_remotes_file(struct remote *remote)\n {\n \tFILE *f = fopen(git_path(\"remotes/%s\", remote->name), \"r\");\n@@ -128,7 +193,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@@ -180,7 +245,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@@ -210,6 +275,19 @@ static int handle_config(const char *key, const char *value)\n \t\t}\n \t\treturn 0;\n \t}\n+\tif (!prefixcmp(key, \"url.\")) {\n+\t\tstruct rewrite *rewrite;\n+\t\tname = key + 5;\n+\t\tsubkey = strrchr(name, '.');\n+\t\tif (!subkey)\n+\t\t\treturn 0;\n+\t\trewrite = make_rewrite(name, subkey - name);\n+\t\tif (!strcmp(subkey, \".aka\")) {\n+\t\t\tif (!value)\n+\t\t\t\treturn config_error_nonbool(key);\n+\t\t\tadd_aka(rewrite, xstrdup(value));\n+\t\t}\n+\t}\n \tif (prefixcmp(key,  \"remote.\"))\n \t\treturn 0;\n \tname = key + 7;\n@@ -261,6 +339,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 < remotes_nr; 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@@ -277,6 +367,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@@ -342,7 +433,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);\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 9d2dc33..4ffe2a1 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -100,6 +100,23 @@ test_expect_success 'fetch with wildcard' '\n \t)\n '\n \n+test_expect_success 'fetch with aka' '\n+\tmk_empty &&\n+\t(\n+\t\tTRASH=$(pwd) &&\n+\t\tcd testrepo &&\n+\t\tgit config url./$TRASH/.aka trash/\n+\t\tgit config remote.up.url trash/. &&\n+\t\tgit config remote.up.fetch \"refs/heads/*:refs/remotes/origin/*\" &&\n+\t\tgit fetch up &&\n+\n+\t\tr=$(git show-ref -s --verify refs/remotes/origin/master) &&\n+\t\ttest \"z$r\" = \"z$the_commit\" &&\n+\n+\t\ttest 1 = $(git for-each-ref refs/remotes/origin | wc -l)\n+\t)\n+'\n+\n test_expect_success 'push without wildcard' '\n \tmk_empty &&\n \n@@ -126,6 +143,20 @@ test_expect_success 'push with wildcard' '\n \t)\n '\n \n+test_expect_success 'push with aka' '\n+\tmk_empty &&\n+\tTRASH=$(pwd) &&\n+\tgit config url./$TRASH/.aka trash/ &&\n+\tgit push trash/testrepo refs/heads/master:refs/remotes/origin/master &&\n+\t(\n+\t\tcd testrepo &&\n+\t\tr=$(git show-ref -s --verify refs/remotes/origin/master) &&\n+\t\ttest \"z$r\" = \"z$the_commit\" &&\n+\n+\t\ttest 1 = $(git for-each-ref refs/remotes/origin | wc -l)\n+\t)\n+'\n+\n test_expect_success 'push with matching heads' '\n \n \tmk_test heads/master &&\n-- \n1.5.4.1.1350.g2b9ee\n"},{"id":"69393","messageId":"7vzltv4ey8.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"alpine.LNX.1.00.0802201337060.19024@iabervon.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-20T19:15:27Z","receivedAt":"2008-02-20T19:15:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?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 by pattern\n> matching across a large set of similiarly set up repositories to each\n> get the desired access.\n>\n> For example, if you don't have a kernel.org account, you might want\n> settings like:\n>\n> [url \"git://git.kernel.org/pub/\"]\n>       aka = master.kernel.org:/pub\n>\n> Then, if you give git a URL like:\n>\n>   master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git\n>\n> it will act like you gave it:\n>\n>   git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git\n>\n> and you can cut-and-paste pull requests in email without fixing them\n> by hand, for example.\n\nTo me, \"url.$this_is_what_I_use.aka = $how_they_might_call_it\"\ninitially felt backwards, but the point of the facility is to\nallow mapping many ways other people might call it to how you\nwould (and the other way would not make sense as allowing to map\none thing to multiple is only to introduce unnecessary\nambiguity), so it makes perfect sense.\n\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index f2f6a77..44f4c4b 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -646,6 +646,11 @@ 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>.rewritebase::\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\nThis still stands???\n\n> diff --git a/Documentation/urls.txt b/Documentation/urls.txt\n> index 81ac17f..0115af7 100644\n> --- a/Documentation/urls.txt\n> +++ b/Documentation/urls.txt\n> @@ -44,3 +44,26 @@ endif::git-clone[]\n> ...\n> +If you have a section:\n> +\n> +------------\n> +\t[host \"git://git.host.xz/\"]\n> +\t\taka = host.xz:/path/to/\n> +\t\taka = work:\n> +------------\n> +\n> +a URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\n> +rewritten in any context that takes a URL to be\n> +\"git://git.host.xz/repo.git\".\n\nThis still stands???\n"},{"id":"69394","messageId":"alpine.LNX.1.00.0802201418590.19024@iabervon.org","threadId":"12220","inReplyTo":"7vzltv4ey8.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-20T19:24:50Z","receivedAt":"2008-02-20T19:24:50Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 20 Feb 2008, Junio C Hamano 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 by pattern\n> > matching across a large set of similiarly set up repositories to each\n> > get the desired access.\n> >\n> > For example, if you don't have a kernel.org account, you might want\n> > settings like:\n> >\n> > [url \"git://git.kernel.org/pub/\"]\n> >       aka = master.kernel.org:/pub\n> >\n> > Then, if you give git a URL like:\n> >\n> >   master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git\n> >\n> > it will act like you gave it:\n> >\n> >   git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git\n> >\n> > and you can cut-and-paste pull requests in email without fixing them\n> > by hand, for example.\n> \n> To me, \"url.$this_is_what_I_use.aka = $how_they_might_call_it\"\n> initially felt backwards, but the point of the facility is to\n> allow mapping many ways other people might call it to how you\n> would (and the other way would not make sense as allowing to map\n> one thing to multiple is only to introduce unnecessary\n> ambiguity), so it makes perfect sense.\n\nThis order of values is definitely the right thing, for the mapping \nreasons you saw. And I think \"aka\" is generally used to indicate \nadditional non-canonical names for something with an official name (see, \nfor example, IMDB's usage). I haven't been able to come up with anything \nbetter to indicate \"this is a name that I will recognize but not use \nmyself\".\n\n> > diff --git a/Documentation/config.txt b/Documentation/config.txt\n> > index f2f6a77..44f4c4b 100644\n> > --- a/Documentation/config.txt\n> > +++ b/Documentation/config.txt\n> > @@ -646,6 +646,11 @@ 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>.rewritebase::\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> This still stands???\n\nOops, didn't quite remove all of it.\n\n> > diff --git a/Documentation/urls.txt b/Documentation/urls.txt\n> > index 81ac17f..0115af7 100644\n> > --- a/Documentation/urls.txt\n> > +++ b/Documentation/urls.txt\n> > @@ -44,3 +44,26 @@ endif::git-clone[]\n> > ...\n> > +If you have a section:\n> > +\n> > +------------\n> > +\t[host \"git://git.host.xz/\"]\n> > +\t\taka = host.xz:/path/to/\n> > +\t\taka = work:\n> > +------------\n> > +\n> > +a URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\n> > +rewritten in any context that takes a URL to be\n> > +\"git://git.host.xz/repo.git\".\n> \n> This still stands???\n\nAnd missed the \"host\"->\"url\" bit while I fixed the rest of the example. \nWant a replacement, or can you make the obvious corrections just as \neasily yourself?\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"69396","messageId":"7vskzn4dpz.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"alpine.LNX.1.00.0802201418590.19024@iabervon.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-20T19:42:00Z","receivedAt":"2008-02-20T19:42:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> On Wed, 20 Feb 2008, Junio C Hamano wrote:\n> ...\n>> To me, \"url.$this_is_what_I_use.aka = $how_they_might_call_it\"\n>> initially felt backwards, but the point of the facility is to\n>> allow mapping many ways other people might call it to how you\n>> would (and the other way would not make sense as allowing to map\n>> one thing to multiple is only to introduce unnecessary\n>> ambiguity), so it makes perfect sense.\n>\n> This order of values is definitely the right thing, for the mapping \n> reasons you saw. And I think \"aka\" is generally used to indicate \n> additional non-canonical names for something with an official name (see, \n> for example, IMDB's usage). I haven't been able to come up with anything \n> better to indicate \"this is a name that I will recognize but not use \n> myself\".\n\nYeah, that \"aka\" is still disturbing.\n\n\t[url A]\n        \taka = B\n\nwould read to me: \"A is also known as B\" but that is clearly not\nwhat it means here.  You would want this:\n\n\t[url A]\n        \taka = B \n\t\taka = C\n\nto mean \"B is also known as A.  C is also known as A.\"  IOW, you\nare using it backwards, because their name is more official and\nyou are using your own unofficial name to call it.\n\nSorry, but I cannot think of a better way to resolve this, other\nthan by spelling the keyword backwards, but that still makes it\n\"aka\".\n\n>> > diff --git a/Documentation/urls.txt b/Documentation/urls.txt\n>> > index 81ac17f..0115af7 100644\n>> > --- a/Documentation/urls.txt\n>> > +++ b/Documentation/urls.txt\n>> > @@ -44,3 +44,26 @@ endif::git-clone[]\n>> > ...\n>> > +If you have a section:\n>> > +\n>> > +------------\n>> > +\t[host \"git://git.host.xz/\"]\n>> > +\t\taka = host.xz:/path/to/\n>> > +\t\taka = work:\n>> > +------------\n>> > +\n>> > +a URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\n>> > +rewritten in any context that takes a URL to be\n>> > +\"git://git.host.xz/repo.git\".\n>> \n>> This still stands???\n>\n> And missed the \"host\"->\"url\" bit while I fixed the rest of the example. \n\nSo this part is not wanted, right?\n\n> Want a replacement, or can you make the obvious corrections just as \n> easily yourself?\n\nIf my above rant about \"aka\" is not a total misunderstanding,\nI'd rather see somebody (could be you, or others on the list) to\ncome up with a better keyword and have a replacement patch based\non it.\n"},{"id":"69398","messageId":"76718490802201149w5a7c0b88udef968f4083190ea@mail.gmail.com","threadId":"12220","inReplyTo":"alpine.LNX.1.00.0802201418590.19024@iabervon.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-20T19:49:06Z","receivedAt":"2008-02-20T19:49:06Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Feb 20, 2008 2:24 PM, Daniel Barkalow <barkalow@iabervon.org> wrote:\n> This order of values is definitely the right thing, for the mapping\n> reasons you saw. And I think \"aka\" is generally used to indicate\n> additional non-canonical names for something with an official name (see,\n> for example, IMDB's usage). I haven't been able to come up with anything\n> better to indicate \"this is a name that I will recognize but not use\n> myself\".\n\nI think the word you want is \"alias\", isn't it? I've never really seen\naka used in a technical sense, whereas alias is used quite often (URL\naliases, DNS aliases, etc). So:\n\nurl.$canonical_name.alias = $local_name.\n\n$0.02.\n\nj.\n"},{"id":"69399","messageId":"76718490802201154t53ff4195xba055b5d42a3759c@mail.gmail.com","threadId":"12220","inReplyTo":"7vskzn4dpz.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-20T19:54:42Z","receivedAt":"2008-02-20T19:54:42Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Feb 20, 2008 2:42 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Yeah, that \"aka\" is still disturbing.\n>\n>         [url A]\n>                 aka = B\n>\n> would read to me: \"A is also known as B\" but that is clearly not\n> what it means here.  You would want this:\n>\n>         [url A]\n>                 aka = B\n>                 aka = C\n>\n> to mean \"B is also known as A.  C is also known as A.\"  IOW, you\n> are using it backwards, because their name is more official and\n> you are using your own unofficial name to call it.\n>\n> Sorry, but I cannot think of a better way to resolve this, other\n> than by spelling the keyword backwards, but that still makes it\n> \"aka\".\n\nI dunno, I find this eminently clear:\n\n        [url A]\n                alias = B\n                alias = C\n\nB and C are aliases for A. How else could you read that?\n\nj.\n"},{"id":"69400","messageId":"7vfxvn4cyh.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"76718490802201149w5a7c0b88udef968f4083190ea@mail.gmail.com","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-20T19:58:30Z","receivedAt":"2008-02-20T19:58:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Jay Soffian\" <jaysoffian@gmail.com> writes:\n\n> On Feb 20, 2008 2:24 PM, Daniel Barkalow <barkalow@iabervon.org> wrote:\n>> This order of values is definitely the right thing, for the mapping\n>> reasons you saw. And I think \"aka\" is generally used to indicate\n>> additional non-canonical names for something with an official name (see,\n>> for example, IMDB's usage). I haven't been able to come up with anything\n>> better to indicate \"this is a name that I will recognize but not use\n>> myself\".\n>\n> I think the word you want is \"alias\", isn't it? I've never really seen\n> aka used in a technical sense, whereas alias is used quite often (URL\n> aliases, DNS aliases, etc). So:\n>\n> url.$canonical_name.alias = $local_name.\n\nRead the first line you quoted, and think again.\n"},{"id":"69402","messageId":"76718490802201222y5bbe09d5j541690669a96672f@mail.gmail.com","threadId":"12220","inReplyTo":"7vfxvn4cyh.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-20T20:22:08Z","receivedAt":"2008-02-20T20:22:08Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Feb 20, 2008 2:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Jay Soffian\" <jaysoffian@gmail.com> writes:\n>\n> > On Feb 20, 2008 2:24 PM, Daniel Barkalow <barkalow@iabervon.org> wrote:\n> >> This order of values is definitely the right thing, for the mapping\n> >> reasons you saw. And I think \"aka\" is generally used to indicate\n> >> additional non-canonical names for something with an official name (see,\n> >> for example, IMDB's usage). I haven't been able to come up with anything\n> >> better to indicate \"this is a name that I will recognize but not use\n> >> myself\".\n> >\n> > I think the word you want is \"alias\", isn't it? I've never really seen\n> > aka used in a technical sense, whereas alias is used quite often (URL\n> > aliases, DNS aliases, etc). So:\n> >\n> > url.$canonical_name.alias = $local_name.\n>\n> Read the first line you quoted, and think again.\n\nWell I'm just not seeing it, but you could you do it just like the\n[alias] section?\n\ngit config url.local canonical\n\n[url]\n  local = canonical\n\ngit config would have to be extended to deal with a URL on the LHS.\n\n\n?\n"},{"id":"69403","messageId":"alpine.LNX.1.00.0802201520450.19024@iabervon.org","threadId":"12220","inReplyTo":"7vskzn4dpz.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-20T20:42:10Z","receivedAt":"2008-02-20T20:42:10Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 20 Feb 2008, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > On Wed, 20 Feb 2008, Junio C Hamano wrote:\n> > ...\n> >> To me, \"url.$this_is_what_I_use.aka = $how_they_might_call_it\"\n> >> initially felt backwards, but the point of the facility is to\n> >> allow mapping many ways other people might call it to how you\n> >> would (and the other way would not make sense as allowing to map\n> >> one thing to multiple is only to introduce unnecessary\n> >> ambiguity), so it makes perfect sense.\n> >\n> > This order of values is definitely the right thing, for the mapping \n> > reasons you saw. And I think \"aka\" is generally used to indicate \n> > additional non-canonical names for something with an official name (see, \n> > for example, IMDB's usage). I haven't been able to come up with anything \n> > better to indicate \"this is a name that I will recognize but not use \n> > myself\".\n> \n> Yeah, that \"aka\" is still disturbing.\n> \n> \t[url A]\n>         \taka = B\n> \n> would read to me: \"A is also known as B\" but that is clearly not\n> what it means here. \n\nBut it is; the thing which we will call \"A\" is also known (and \nsometimes called by other people, or us speaking informally) as \"B\".\n\n> You would want this:\n> \n> \t[url A]\n>         \taka = B \n> \t\taka = C\n> \n> to mean \"B is also known as A.  C is also known as A.\"  IOW, you\n> are using it backwards, because their name is more official and\n> you are using your own unofficial name to call it.\n\nNo, \"A\" is the *real* name, the one that actually works. B and C are \npseudonyms, of which there may be multiple, both from more \"official\" (but \ngit is decentralized, and doesn't care for officialness) and less official \nsources.\n\nI think you're seeing this feature as taking \"correct\" URLs and rewriting \nthem to be local aliases, when the only thing that makes sense for a \nsystem like git is really to say that whatever URL works for us is \n\"correct\", and everybody else is speaking their own local dialect.\n\nIn fact, one case I anticipate using extensively is:\n\n[url \"git://iabervon.org/~barkalow/\"]\n\taka = \":\"\n\nSuch that, once clone is using remote.{c,h}, \"git clone :git\" would clone \nmy home git repository. Obviously \":\" isn't the real name in this \nrewriting.\n\n> >> > diff --git a/Documentation/urls.txt b/Documentation/urls.txt\n> >> > index 81ac17f..0115af7 100644\n> >> > --- a/Documentation/urls.txt\n> >> > +++ b/Documentation/urls.txt\n> >> > @@ -44,3 +44,26 @@ endif::git-clone[]\n> >> > ...\n> >> > +If you have a section:\n> >> > +\n> >> > +------------\n> >> > +\t[host \"git://git.host.xz/\"]\n> >> > +\t\taka = host.xz:/path/to/\n> >> > +\t\taka = work:\n> >> > +------------\n> >> > +\n> >> > +a URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\n> >> > +rewritten in any context that takes a URL to be\n> >> > +\"git://git.host.xz/repo.git\".\n> >> \n> >> This still stands???\n> >\n> > And missed the \"host\"->\"url\" bit while I fixed the rest of the example. \n> \n> So this part is not wanted, right?\n\nThe first part (not quoted) is not wanted (it was left over from when I \ncombined the three entries into one and moved it under 'u' instead of \n'h'). This part *is* wanted, but should say:\n\n+\t[url \"git://git.host.xz/\"]\n\ninstead of\n\n+\t[host \"git://git.host.xz/\"]\n\nsince I changed the option name.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"69405","messageId":"200802202203.m1KM37aR012221@mi1.bluebottle.com","threadId":"12220","inReplyTo":"7vskzn4dpz.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"しらいしななこ","fromEmail":"nanako3@bluebottle.com","sentAt":"2008-02-20T22:02:09Z","receivedAt":"2008-02-20T22:02:09Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Junio C Hamano <gitster@pobox.com>:\n\n> Yeah, that \"aka\" is still disturbing.\n>\n> \t[url A]\n>         \taka = B\n>\n> would read to me: \"A is also known as B\" but that is clearly not\n> what it means here.  You would want this:\n>\n> \t[url A]\n>         \taka = B \n> \t\taka = C\n>\n> to mean \"B is also known as A.  C is also known as A.\"  IOW, you\n> are using it backwards, because their name is more official and\n> you are using your own unofficial name to call it.\n>\n> Sorry, but I cannot think of a better way to resolve this, other\n> than by spelling the keyword backwards, but that still makes it\n> \"aka\".\n\nIsn't what you mean to say \"A stands for B and C\"?\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n\n----------------------------------------------------------------------\nFind out how you can get spam free email.\nhttp://www.bluebottle.com/tag/3\n"},{"id":"69411","messageId":"alpine.LSU.1.00.0802202221130.17164@racer.site","threadId":"12220","inReplyTo":"200802202203.m1KM37aR012221@mi1.bluebottle.com","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-20T22:22:22Z","receivedAt":"2008-02-20T22:22:22Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 21 Feb 2008, しらいしななこ wrote:\n\n> Quoting Junio C Hamano <gitster@pobox.com>:\n> \n> > Yeah, that \"aka\" is still disturbing.\n> >\n> > \t[url A]\n> >         \taka = B\n> >\n> > would read to me: \"A is also known as B\" but that is clearly not\n> > what it means here.  You would want this:\n> >\n> > \t[url A]\n> >         \taka = B \n> > \t\taka = C\n> >\n> > to mean \"B is also known as A.  C is also known as A.\"  IOW, you\n> > are using it backwards, because their name is more official and\n> > you are using your own unofficial name to call it.\n> >\n> > Sorry, but I cannot think of a better way to resolve this, other\n> > than by spelling the keyword backwards, but that still makes it\n> > \"aka\".\n> \n> Isn't what you mean to say \"A stands for B and C\"?\n\nSo you mean\n\n[url A]\n\tstandsFor = B\n\tstandsFor = C\n\n? ;-)\n\nThis might be seen as bike-shedding by some, but I think that it is \nactually worthwhile to kick back and forth some ideas, and pick the best \none.\n\nCiao,\nDscho\n"},{"id":"69439","messageId":"7v4pc316gq.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"alpine.LSU.1.00.0802202221130.17164@racer.site","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-21T00:47:01Z","receivedAt":"2008-02-21T00:47:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> So you mean\n>\n> [url A]\n> \tstandsFor = B\n> \tstandsFor = C\n>\n> ? ;-)\n>\n> This might be seen as bike-shedding by some, but I think that it is \n> actually worthwhile to kick back and forth some ideas, and pick the best \n> one.\n\nIt appears that Daniel and I disagree which one we should\nconsider canonical and which one substitute.  I tend to think\nwhat you would see in the mailing list announce (B and C) are\ncanonical and you rewrite them to adjust to your local needs\n(A).  But Daniel has a point that to the environment that needs\nto access the repository as A, that name is the canonical one.\n\nI am not very much interested in resolving which one is which.\n\nIn either case, I think a good approach to take is to find a\nwording that conveys the notion \"I will use A to mean what some\nother people might call B or C\" unambiguously.\n\nWhen you have the above in $HOME/.gitconfig, it would mean \n\"To me, A stands for B or C\".  If you have it in .git/config of\nthe project, you are saying \"When pushing/fetching in this\nrepository, A stands for B or C\".  I think that is a reasonable\nway to express what we want.\n"},{"id":"69440","messageId":"76718490802201726t677b1498ma3bdb3dbf25dd781@mail.gmail.com","threadId":"12220","inReplyTo":"7v4pc316gq.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-21T01:26:07Z","receivedAt":"2008-02-21T01:26:07Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 20, 2008 at 7:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>  In either case, I think a good approach to take is to find a\n>  wording that conveys the notion \"I will use A to mean what some\n>  other people might call B or C\" unambiguously.\n\n[url A]\n  other_people_call_it = B\n  other_people_call_it = C\n\n[local_url A]\n  external_url = B\n  external_url = C\nj.\n"},{"id":"69443","messageId":"alpine.LFD.1.00.0802201735030.7833@woody.linux-foundation.org","threadId":"12220","inReplyTo":"76718490802201726t677b1498ma3bdb3dbf25dd781@mail.gmail.com","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-02-21T01:47:58Z","receivedAt":"2008-02-21T01:47:58Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 20 Feb 2008, Jay Soffian wrote:\n\n> On Wed, Feb 20, 2008 at 7:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> >\n> >  In either case, I think a good approach to take is to find a\n> >  wording that conveys the notion \"I will use A to mean what some\n> >  other people might call B or C\" unambiguously.\n> \n> [url A]\n>   other_people_call_it = B\n>   other_people_call_it = C\n> \n> [local_url A]\n>   external_url = B\n>   external_url = C\n\nWell, realistically, what's really the use of this?\n\nThe only really sane use of this is the one that Daniel started out with: \nyou may have a \"external\" representation of a name, but for your own \npurely local configuration reasons, you may want to map that name into \nanother one that works for you.\n\nThe reason may be some local protocol issue: let's say that you see all \nthese pointers to git://git.kernel.org/ flying around, because that is the \nofficial home of the git repository itself, but you work at a company that \nhas a firewall that doesn't let git through. So you want to still *use* \nthose names that other people use, but you want to remap them through some \nproxy server (or a local cache), or just to use ssh instead.\n\nSo it's generally *not* that it's an \"alias\" for another site, since it \nisn't that in general - it may just be a very local configuration thing. \nIt's also not really that you would call it one thing and others would \ncall it another thing: you want to call it the *same* thing as others call \nit, but you want to work around some specific site issue (or just use a \ncache that is closer without having to think about it).\n\nSo I think it really boils down to the fact that you want to \"rewrite\" the \nthing. Not aliases, not \"also known as\", but you're logically really \nlooking for something like \n\n\t[access \"git://git.kernel.org/*\"]\n\t\tproxy = proxy-program\n\t\turl = \"ssh://master.kernel.org/*\"\n\nwhich admittedly looks rather strange too, but at the same time it does \nmake sense from a \"what do we really want to do?\" standpoint.\n\nOf course, in this case Daniel didn't actually do that \"proxy\" part, but I \nthink the argument that we should try to make the config file syntax \ndescribe what the user wants to do is still very true. So skip that \n\"proxy\" part (maybe somebody wants to do that too some day), and leave the \n\n\t[access \"original\"]\n\t\turl = \"rewritten\"\n\nkind of syntax.\n\n(And no, I'm not at all married to the \"access\" and \"url\" parts - I don't \ncare. I'm just saying that syntax should be tied to what people want to \ndo, not anything else.\n\n\t\t\t\tLinus\n"},{"id":"69444","messageId":"76718490802201819g6e2662afjdcbbacadb2521106@mail.gmail.com","threadId":"12220","inReplyTo":"alpine.LFD.1.00.0802201735030.7833@woody.linux-foundation.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2008-02-21T02:19:31Z","receivedAt":"2008-02-21T02:19:31Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 20, 2008 at 8:47 PM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n\n>  So I think it really boils down to the fact that you want to \"rewrite\" the\n>  thing. Not aliases, not \"also known as\", but you're logically really\n>  looking for something like\n>\n>         [access \"git://git.kernel.org/*\"]\n>                 proxy = proxy-program\n>                 url = \"ssh://master.kernel.org/*\"\n>\n>  which admittedly looks rather strange too, but at the same time it does\n>  make sense from a \"what do we really want to do?\" standpoint.\n>\n>  Of course, in this case Daniel didn't actually do that \"proxy\" part, but I\n>  think the argument that we should try to make the config file syntax\n>  describe what the user wants to do is still very true. So skip that\n>  \"proxy\" part (maybe somebody wants to do that too some day), and leave the\n>\n>         [access \"original\"]\n>                 url = \"rewritten\"\n>\n>  kind of syntax.\n>\n>  (And no, I'm not at all married to the \"access\" and \"url\" parts - I don't\n>  care. I'm just saying that syntax should be tied to what people want to\n>  do, not anything else.\n\nShrug:\n\n[core]\n  rewriterule = <from> <to>\n  ; ...\n\nIf <from> or <to> contain whitespace then you have to use %20 or quotes.\n\n(There is already proxy support elsewhere in the config.)\n\nI think I'm done suggesting paint colors. :-)\n\nj.\n"},{"id":"69451","messageId":"alpine.LNX.1.00.0802202351400.19024@iabervon.org","threadId":"12220","inReplyTo":"alpine.LFD.1.00.0802201735030.7833@woody.linux-foundation.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-21T05:04:38Z","receivedAt":"2008-02-21T05:04:38Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 20 Feb 2008, Linus Torvalds wrote:\n\n> On Wed, 20 Feb 2008, Jay Soffian wrote:\n> \n> > On Wed, Feb 20, 2008 at 7:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> > >\n> > >  In either case, I think a good approach to take is to find a\n> > >  wording that conveys the notion \"I will use A to mean what some\n> > >  other people might call B or C\" unambiguously.\n> > \n> > [url A]\n> >   other_people_call_it = B\n> >   other_people_call_it = C\n> > \n> > [local_url A]\n> >   external_url = B\n> >   external_url = C\n> \n> Well, realistically, what's really the use of this?\n> \n> The only really sane use of this is the one that Daniel started out with: \n> you may have a \"external\" representation of a name, but for your own \n> purely local configuration reasons, you may want to map that name into \n> another one that works for you.\n> \n> The reason may be some local protocol issue: let's say that you see all \n> these pointers to git://git.kernel.org/ flying around, because that is the \n> official home of the git repository itself, but you work at a company that \n> has a firewall that doesn't let git through. So you want to still *use* \n> those names that other people use, but you want to remap them through some \n> proxy server (or a local cache), or just to use ssh instead.\n> \n> So it's generally *not* that it's an \"alias\" for another site, since it \n> isn't that in general - it may just be a very local configuration thing. \n> It's also not really that you would call it one thing and others would \n> call it another thing: you want to call it the *same* thing as others call \n> it, but you want to work around some specific site issue (or just use a \n> cache that is closer without having to think about it).\n> \n> So I think it really boils down to the fact that you want to \"rewrite\" the \n> thing. Not aliases, not \"also known as\", but you're logically really \n> looking for something like \n> \n> \t[access \"git://git.kernel.org/*\"]\n> \t\tproxy = proxy-program\n> \t\turl = \"ssh://master.kernel.org/*\"\n> \n> which admittedly looks rather strange too, but at the same time it does \n> make sense from a \"what do we really want to do?\" standpoint.\n> \n> Of course, in this case Daniel didn't actually do that \"proxy\" part, but I \n> think the argument that we should try to make the config file syntax \n> describe what the user wants to do is still very true. So skip that \n> \"proxy\" part (maybe somebody wants to do that too some day), and leave the \n> \n> \t[access \"original\"]\n> \t\turl = \"rewritten\"\n> \n> kind of syntax.\n\nI think it has to be:\n\n\t[something \"rewritten\"]\n\t\tsomething = \"original\"\n\t\tsomething = \"other original\"\n\nBecause you want to be able to take multiple \"original\"s for the same \nresult in order to avoid duplicating that part (and leading to skew if you \ndecide to change). But I like the idea of basing the naming on the \nrewriting operation rather than the relationship. Maybe:\n\n[url \"rewritten\"]\n\tinsteadOf = \"original\"\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"69456","messageId":"7vk5kyyirk.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"alpine.LNX.1.00.0802202351400.19024@iabervon.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-21T05:34:55Z","receivedAt":"2008-02-21T05:34:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> [url \"rewritten\"]\n> \tinsteadOf = \"original\"\n\nThat's much clearer than anything I've seen in this thread which\none is the one you cannot use yourself and which one is what you\nhave to use to get it to work.\n"},{"id":"69489","messageId":"47BDA74D.8080608@freescale.com","threadId":"12220","inReplyTo":"alpine.LFD.1.00.0802201735030.7833@woody.linux-foundation.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Jon Loeliger","fromEmail":"jdl@freescale.com","sentAt":"2008-02-21T16:31:09Z","receivedAt":"2008-02-21T16:31:09Z","isPatch":true,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"Linus Torvalds wrote:\n> \n> The only really sane use of this is the one that Daniel started out with: \n> you may have a \"external\" representation of a name, but for your own \n> purely local configuration reasons, you may want to map that name into \n> another one that works for you.\n> \n\n[ snip ]\n\n> So it's generally *not* that it's an \"alias\" for another site, since it \n> isn't that in general - it may just be a very local configuration thing. \n> It's also not really that you would call it one thing and others would \n> call it another thing: you want to call it the *same* thing as others call \n> it, but you want to work around some specific site issue (or just use a \n> cache that is closer without having to think about it).\n\nI totally agree with all that.\n\n> \t[access \"git://git.kernel.org/*\"]\n> \t\tproxy = proxy-program\n> \t\turl = \"ssh://master.kernel.org/*\"\n> \n> which admittedly looks rather strange too, but at the same time it does \n> make sense from a \"what do we really want to do?\" standpoint.\n> \n> Of course, in this case Daniel didn't actually do that \"proxy\" part, but I \n> think the argument that we should try to make the config file syntax \n> describe what the user wants to do is still very true. So skip that \n> \"proxy\" part (maybe somebody wants to do that too some day), and leave the \n> \n> \t[access \"original\"]\n> \t\turl = \"rewritten\"\n> \n> kind of syntax.\n> \n> (And no, I'm not at all married to the \"access\" and \"url\" parts - I don't \n> care. I'm just saying that syntax should be tied to what people want to \n> do, not anything else.\n\nRight.  And I think part of the issue is, which of the two forms will\nbe present in the user's git requests?  He'd _like_ to use the same,\ncanonical name everyone else does, but for whatever reason, it has to\nbe rewritten for the actual transportation implementation to work.\nSort of like virtual/physical address definitions here?\n\n    [virtual_url \"git://git.kernel.org/\"]\n        physical_url = \"ssh://master.kernel.org/\"\n\nBut maybe it needs to be:\n\n    physical_url [\"ssh://master.kernel.org/\"]\n        virtual_url = \"git://git.kernel.org/\"\n        virtual_url = \"git://kernel.org/\"\n\nThe git user would use the virtual_url, but it would be translated\nto the physical_url for the underlying implementation to work.\n\nI think it is more than paint coloring at work here.  The important\npart is to convey the concepts properly with the names.  The reader\nof the config file has to be able to tell which way the mapping is run.\n\njdl\n"},{"id":"69847","messageId":"7vwsotoey8.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"7vk5kyyirk.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-25T04:08:47Z","receivedAt":"2008-02-25T04:08:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n>\n>> [url \"rewritten\"]\n>> \tinsteadOf = \"original\"\n>\n> That's much clearer than anything I've seen in this thread which\n> one is the one you cannot use yourself and which one is what you\n> have to use to get it to work.\n\nAlthough I am willing to step in when they need help, I usually\ntry not to finish up other people's patches, especially when I\nknow they are capable.\n\nBut I wanted to take 'next' into a shape as close to the -rc1 as\npossible early, so here is my stab at it.  This will be in 'next'\ntonight.\n\nThe patch is relative to your:\n\n    Date: Wed, 20 Feb 2008 13:43:53 -0500 (EST)\n    Subject: [PATCH 2/2] Add support for url aliases in config files\n    Message-ID: <alpine.LNX.1.00.0802201337060.19024@iabervon.org>\n\naka\n\n    http://article.gmane.org/gmane.comp.version-control.git/74535\n\nbased on the earlier discussions.\n\n * The first hunk to Documentation/config.txt which was a\n   leftover from the previous round is dropped.\n\n * Fixed s/host/url/ in Documentation/config.txt, which was also\n   a leftover from the previous round.\n\n * The result is undefined if you have this:\n\n\t[url \"foo\"]\n        \tinsteadOf = \"baz\"\n\t[url \"bar\"]\n        \tinsteadOf = \"baz\"\n\n   I tried to clarify the handling of this misconfiguration by\n   rewording, but I do not know how successful I was.\n\n * s/aka/insteadOf/ everywhere.\n\n---\n\n Documentation/config.txt |   10 +++-------\n Documentation/urls.txt   |   14 +++++++-------\n remote.c                 |   24 ++++++++++++------------\n t/t5516-fetch-push.sh    |    8 ++++----\n 4 files changed, 26 insertions(+), 30 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 44f4c4b..2981389 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -646,11 +646,6 @@ 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>.rewritebase::\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\n@@ -891,7 +886,7 @@ tar.umask::\n \tarchiving user's umask will be used instead.  See umask(2) and\n \tlinkgit:git-archive[1].\n \n-url.<base>.aka::\n+url.<base>.insteadOf::\n \tAny URL that starts with this value will be rewritten to\n \tstart, instead, with <base>. In cases where some site serves a\n \tlarge number of repositories, and serves them with multiple\n@@ -900,7 +895,8 @@ url.<base>.aka::\n \tequivalent URLs and have git automatically rewrite the URL to\n \tthe best alternative for the particular user, even for a\n \tnever-before-seen repository on the site. The effect of\n-\thaving multiple aka values match is undefined.\n+\thaving multiple `insteadOf` values from different\n+\t`<base>` match to an URL is undefined.\n \n user.email::\n \tYour email address to be recorded in any newly created commits.\ndiff --git a/Documentation/urls.txt b/Documentation/urls.txt\nindex 0115af7..fa34c67 100644\n--- a/Documentation/urls.txt\n+++ b/Documentation/urls.txt\n@@ -53,17 +53,17 @@ configuration section of the form:\n \n ------------\n \t[url \"<actual url base>\"]\n-\t\taka = <other url base>\n+\t\tinsteadOf = <other url base>\n ------------\n \n-If you have a section:\n+For example, with this:\n \n ------------\n-\t[host \"git://git.host.xz/\"]\n-\t\taka = host.xz:/path/to/\n-\t\taka = work:\n+\t[url \"git://git.host.xz/\"]\n+\t\tinsteadOf = host.xz:/path/to/\n+\t\tinsteadOf = work:\n ------------\n \n a URL like \"work:repo.git\" or like \"host.xz:/path/to/repo.git\" will be\n-rewritten in any context that takes a URL to be\n-\"git://git.host.xz/repo.git\".\n+rewritten in any context that takes a URL to be \"git://git.host.xz/repo.git\".\n+\ndiff --git a/remote.c b/remote.c\nindex f8ee38e..0012954 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -4,9 +4,9 @@\n \n struct rewrite {\n \tconst char *base;\n-\tconst char **aka;\n-\tint aka_nr;\n-\tint aka_alloc;\n+\tconst char **instead_of;\n+\tint instead_of_nr;\n+\tint instead_of_alloc;\n };\n \n static struct remote **remotes;\n@@ -33,13 +33,13 @@ static const char *alias_url(const char *url)\n \tfor (i = 0; i < rewrite_nr; i++) {\n \t\tif (!rewrite[i])\n \t\t\tcontinue;\n-\t\tfor (j = 0; j < rewrite[i]->aka_nr; j++) {\n-\t\t\tif (!prefixcmp(url, rewrite[i]->aka[j])) {\n+\t\tfor (j = 0; j < rewrite[i]->instead_of_nr; j++) {\n+\t\t\tif (!prefixcmp(url, rewrite[i]->instead_of[j])) {\n \t\t\t\tchar *ret = malloc(strlen(rewrite[i]->base) -\n-\t\t\t\t\t\t   strlen(rewrite[i]->aka[j]) +\n+\t\t\t\t\t\t   strlen(rewrite[i]->instead_of[j]) +\n \t\t\t\t\t\t   strlen(url) + 1);\n \t\t\t\tstrcpy(ret, rewrite[i]->base);\n-\t\t\t\tstrcat(ret, url + strlen(rewrite[i]->aka[j]));\n+\t\t\t\tstrcat(ret, url + strlen(rewrite[i]->instead_of[j]));\n \t\t\t\treturn ret;\n \t\t\t}\n \t\t}\n@@ -154,10 +154,10 @@ static struct rewrite *make_rewrite(const char *base, int len)\n \treturn ret;\n }\n \n-static void add_aka(struct rewrite *rewrite, const char *aka)\n+static void add_instead_of(struct rewrite *rewrite, const char *instead_of)\n {\n-\tALLOC_GROW(rewrite->aka, rewrite->aka_nr + 1, rewrite->aka_alloc);\n-\trewrite->aka[rewrite->aka_nr++] = aka;\n+\tALLOC_GROW(rewrite->instead_of, rewrite->instead_of_nr + 1, rewrite->instead_of_alloc);\n+\trewrite->instead_of[rewrite->instead_of_nr++] = instead_of;\n }\n \n static void read_remotes_file(struct remote *remote)\n@@ -282,10 +282,10 @@ static int handle_config(const char *key, const char *value)\n \t\tif (!subkey)\n \t\t\treturn 0;\n \t\trewrite = make_rewrite(name, subkey - name);\n-\t\tif (!strcmp(subkey, \".aka\")) {\n+\t\tif (!strcmp(subkey, \".insteadof\")) {\n \t\t\tif (!value)\n \t\t\t\treturn config_error_nonbool(key);\n-\t\t\tadd_aka(rewrite, xstrdup(value));\n+\t\t\tadd_instead_of(rewrite, xstrdup(value));\n \t\t}\n \t}\n \tif (prefixcmp(key,  \"remote.\"))\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 4ffe2a1..9023ba0 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -100,12 +100,12 @@ test_expect_success 'fetch with wildcard' '\n \t)\n '\n \n-test_expect_success 'fetch with aka' '\n+test_expect_success 'fetch with insteadOf' '\n \tmk_empty &&\n \t(\n \t\tTRASH=$(pwd) &&\n \t\tcd testrepo &&\n-\t\tgit config url./$TRASH/.aka trash/\n+\t\tgit config url./$TRASH/.insteadOf trash/\n \t\tgit config remote.up.url trash/. &&\n \t\tgit config remote.up.fetch \"refs/heads/*:refs/remotes/origin/*\" &&\n \t\tgit fetch up &&\n@@ -143,10 +143,10 @@ test_expect_success 'push with wildcard' '\n \t)\n '\n \n-test_expect_success 'push with aka' '\n+test_expect_success 'push with insteadOf' '\n \tmk_empty &&\n \tTRASH=$(pwd) &&\n-\tgit config url./$TRASH/.aka trash/ &&\n+\tgit config url./$TRASH/.insteadOf trash/ &&\n \tgit push trash/testrepo refs/heads/master:refs/remotes/origin/master &&\n \t(\n \t\tcd testrepo &&\n"},{"id":"69848","messageId":"alpine.LNX.1.00.0802242319200.19024@iabervon.org","threadId":"12220","inReplyTo":"7vwsotoey8.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-25T04:30:30Z","receivedAt":"2008-02-25T04:30:30Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 24 Feb 2008, Junio C Hamano wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > Daniel Barkalow <barkalow@iabervon.org> writes:\n> >\n> >> [url \"rewritten\"]\n> >> \tinsteadOf = \"original\"\n> >\n> > That's much clearer than anything I've seen in this thread which\n> > one is the one you cannot use yourself and which one is what you\n> > have to use to get it to work.\n> \n> Although I am willing to step in when they need help, I usually\n> try not to finish up other people's patches, especially when I\n> know they are capable.\n> \n> But I wanted to take 'next' into a shape as close to the -rc1 as\n> possible early, so here is my stab at it.  This will be in 'next'\n> tonight.\n\nThanks; that's exactly what I would have done (assuming I didn't miss \nplaces like last time). Except that it should say that it's still \nundefined if you use:\n\n        [url \"foo\"]\n                insteadOf = \"baz\"\n        [url \"bar\"]\n                insteadOf = \"baz/sub\"\n\nin that you can't predict whether \"baz/sub/a\" will be \"bar/a\" or \n\"foo/sub/a\". This is actually what I'm most concerned about, since there \nis actually a logical expectation (the one that matches more will be used \nin preference to the less specific one), but that's not implemented. \nSomeday, we'll probably want to implement it, and that'll change the \nbehavior of this particular case.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"69850","messageId":"7vfxvho8r7.fsf@gitster.siamese.dyndns.org","threadId":"12220","inReplyTo":"alpine.LNX.1.00.0802242319200.19024@iabervon.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-25T06:22:36Z","receivedAt":"2008-02-25T06:22:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> Thanks; that's exactly what I would have done (assuming I didn't miss \n> places like last time). Except that it should say that it's still \n> undefined if you use:\n>\n>         [url \"foo\"]\n>                 insteadOf = \"baz\"\n>         [url \"bar\"]\n>                 insteadOf = \"baz/sub\"\n>\n> in that you can't predict whether \"baz/sub/a\" will be \"bar/a\" or \n> \"foo/sub/a\". This is actually what I'm most concerned about, since there \n> is actually a logical expectation (the one that matches more will be used \n> in preference to the less specific one), but that's not implemented. \n> Someday, we'll probably want to implement it, and that'll change the \n> behavior of this particular case.\n\nI'd say that that is a reasonable expectation, and it would be\nfair to say that if we have it, the topic will be in 1.5.5 and\notherwise it won't.\n\nThis might be a bit over-engineered, but should do the job.\n\n---\n Documentation/config.txt |    5 +--\n remote.c                 |   54 ++++++++++++++++++++++++++++++++-------------\n 2 files changed, 40 insertions(+), 19 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 2981389..57b9b99 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -894,9 +894,8 @@ url.<base>.insteadOf::\n \tmethods, this feature allows people to specify any of the\n \tequivalent URLs and have git automatically rewrite the URL to\n \tthe best alternative for the particular user, even for a\n-\tnever-before-seen repository on the site. The effect of\n-\thaving multiple `insteadOf` values from different\n-\t`<base>` match to an URL is undefined.\n+\tnever-before-seen repository on the site.  When more than one\n+\tinsteadOf strings match a given URL, the longest match is used.\n \n user.email::\n \tYour email address to be recorded in any newly created commits.\ndiff --git a/remote.c b/remote.c\nindex 0012954..1f83696 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -2,9 +2,14 @@\n #include \"remote.h\"\n #include \"refs.h\"\n \n+struct counted_string {\n+\tsize_t len;\n+\tconst char *s;\n+};\n struct rewrite {\n \tconst char *base;\n-\tconst char **instead_of;\n+\tsize_t baselen;\n+\tstruct counted_string *instead_of;\n \tint instead_of_nr;\n \tint instead_of_alloc;\n };\n@@ -30,21 +35,32 @@ static char buffer[BUF_SIZE];\n static const char *alias_url(const char *url)\n {\n \tint i, j;\n+\tchar *ret;\n+\tstruct counted_string *longest;\n+\tint longest_i;\n+\n+\tlongest = NULL;\n+\tlongest_i = -1;\n \tfor (i = 0; i < rewrite_nr; i++) {\n \t\tif (!rewrite[i])\n \t\t\tcontinue;\n \t\tfor (j = 0; j < rewrite[i]->instead_of_nr; j++) {\n-\t\t\tif (!prefixcmp(url, rewrite[i]->instead_of[j])) {\n-\t\t\t\tchar *ret = malloc(strlen(rewrite[i]->base) -\n-\t\t\t\t\t\t   strlen(rewrite[i]->instead_of[j]) +\n-\t\t\t\t\t\t   strlen(url) + 1);\n-\t\t\t\tstrcpy(ret, rewrite[i]->base);\n-\t\t\t\tstrcat(ret, url + strlen(rewrite[i]->instead_of[j]));\n-\t\t\t\treturn ret;\n+\t\t\tif (!prefixcmp(url, rewrite[i]->instead_of[j].s) &&\n+\t\t\t    (!longest ||\n+\t\t\t     longest->len < rewrite[i]->instead_of[j].len)) {\n+\t\t\t\tlongest = &(rewrite[i]->instead_of[j]);\n+\t\t\t\tlongest_i = i;\n \t\t\t}\n \t\t}\n \t}\n-\treturn url;\n+\tif (!longest)\n+\t\treturn url;\n+\n+\tret = malloc(rewrite[longest_i]->baselen +\n+\t\t     (strlen(url) - longest->len) + 1);\n+\tstrcpy(ret, rewrite[longest_i]->base);\n+\tstrcpy(ret + rewrite[longest_i]->baselen, url + longest->len);\n+\treturn ret;\n }\n \n static void add_push_refspec(struct remote *remote, const char *ref)\n@@ -137,27 +153,33 @@ static struct rewrite *make_rewrite(const char *base, int len)\n \tint i;\n \n \tfor (i = 0; i < rewrite_nr; i++) {\n-\t\tif (len ? (!strncmp(base, rewrite[i]->base, len) &&\n-\t\t\t   !rewrite[i]->base[len]) :\n-\t\t    !strcmp(base, rewrite[i]->base))\n+\t\tif (len\n+\t\t    ? (len == rewrite[i]->baselen &&\n+\t\t       !strncmp(base, rewrite[i]->base, len))\n+\t\t    : !strcmp(base, rewrite[i]->base))\n \t\t\treturn rewrite[i];\n \t}\n \n \tALLOC_GROW(rewrite, rewrite_nr + 1, rewrite_alloc);\n \tret = xcalloc(1, sizeof(struct rewrite));\n \trewrite[rewrite_nr++] = ret;\n-\tif (len)\n+\tif (len) {\n \t\tret->base = xstrndup(base, len);\n-\telse\n+\t\tret->baselen = len;\n+\t}\n+\telse {\n \t\tret->base = xstrdup(base);\n-\n+\t\tret->baselen = strlen(base);\n+\t}\n \treturn ret;\n }\n \n static void add_instead_of(struct rewrite *rewrite, const char *instead_of)\n {\n \tALLOC_GROW(rewrite->instead_of, rewrite->instead_of_nr + 1, rewrite->instead_of_alloc);\n-\trewrite->instead_of[rewrite->instead_of_nr++] = instead_of;\n+\trewrite->instead_of[rewrite->instead_of_nr].s = instead_of;\n+\trewrite->instead_of[rewrite->instead_of_nr].len = strlen(instead_of);\n+\trewrite->instead_of_nr++;\n }\n \n static void read_remotes_file(struct remote *remote)\n"},{"id":"69851","messageId":"alpine.LNX.1.00.0802250130310.19024@iabervon.org","threadId":"12220","inReplyTo":"7vfxvho8r7.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Add support for url aliases in config files","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-25T06:35:27Z","receivedAt":"2008-02-25T06:35:27Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 24 Feb 2008, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > Thanks; that's exactly what I would have done (assuming I didn't miss \n> > places like last time). Except that it should say that it's still \n> > undefined if you use:\n> >\n> >         [url \"foo\"]\n> >                 insteadOf = \"baz\"\n> >         [url \"bar\"]\n> >                 insteadOf = \"baz/sub\"\n> >\n> > in that you can't predict whether \"baz/sub/a\" will be \"bar/a\" or \n> > \"foo/sub/a\". This is actually what I'm most concerned about, since there \n> > is actually a logical expectation (the one that matches more will be used \n> > in preference to the less specific one), but that's not implemented. \n> > Someday, we'll probably want to implement it, and that'll change the \n> > behavior of this particular case.\n> \n> I'd say that that is a reasonable expectation, and it would be\n> fair to say that if we have it, the topic will be in 1.5.5 and\n> otherwise it won't.\n> \n> This might be a bit over-engineered, but should do the job.\n\nVery nice. And if we've got your over-engineered prefix-replacement code \nhere, maybe I'll use it to also do the prefix-replacement for refspec \npatterns.\n\nAcked-by: Daniel Barkalow <barkalow@iabervon.org>\n\n\t-Daniel\n*This .sig left intentionally blank*\n"}]}