From: Junio C Hamano <gitster@pobox.com>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Jay Soffian" <jaysoffian@gmail.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
しらいしななこ <nanako3@bluebottle.com>,
git@vger.kernel.org
Subject: Re: [PATCH 2/2] Add support for url aliases in config files
Date: Sun, 24 Feb 2008 20:08:47 -0800 [thread overview]
Message-ID: <7vwsotoey8.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vk5kyyirk.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 20 Feb 2008 21:34:55 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> Daniel Barkalow <barkalow@iabervon.org> writes:
>
>> [url "rewritten"]
>> insteadOf = "original"
>
> That's much clearer than anything I've seen in this thread which
> one is the one you cannot use yourself and which one is what you
> have to use to get it to work.
Although I am willing to step in when they need help, I usually
try not to finish up other people's patches, especially when I
know they are capable.
But I wanted to take 'next' into a shape as close to the -rc1 as
possible early, so here is my stab at it. This will be in 'next'
tonight.
The patch is relative to your:
Date: Wed, 20 Feb 2008 13:43:53 -0500 (EST)
Subject: [PATCH 2/2] Add support for url aliases in config files
Message-ID: <alpine.LNX.1.00.0802201337060.19024@iabervon.org>
aka
http://article.gmane.org/gmane.comp.version-control.git/74535
based on the earlier discussions.
* The first hunk to Documentation/config.txt which was a
leftover from the previous round is dropped.
* Fixed s/host/url/ in Documentation/config.txt, which was also
a leftover from the previous round.
* The result is undefined if you have this:
[url "foo"]
insteadOf = "baz"
[url "bar"]
insteadOf = "baz"
I tried to clarify the handling of this misconfiguration by
rewording, but I do not know how successful I was.
* s/aka/insteadOf/ everywhere.
---
Documentation/config.txt | 10 +++-------
Documentation/urls.txt | 14 +++++++-------
remote.c | 24 ++++++++++++------------
t/t5516-fetch-push.sh | 8 ++++----
4 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 44f4c4b..2981389 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -646,11 +646,6 @@ help.format::
Values 'man', 'info', 'web' and 'html' are supported. 'man' is
the default. 'web' and 'html' are the same.
-host.<name>.rewritebase::
- Additional base URLs which refer to this host. If a URL
- matches this, any access to it will use the URL formed with
- the corresponding base URL instead of the given URL.
-
http.proxy::
Override the HTTP proxy, normally configured using the 'http_proxy'
environment variable (see linkgit:curl[1]). This can be overridden
@@ -891,7 +886,7 @@ tar.umask::
archiving user's umask will be used instead. See umask(2) and
linkgit:git-archive[1].
-url.<base>.aka::
+url.<base>.insteadOf::
Any URL that starts with this value will be rewritten to
start, instead, with <base>. In cases where some site serves a
large number of repositories, and serves them with multiple
@@ -900,7 +895,8 @@ url.<base>.aka::
equivalent URLs and have git automatically rewrite the URL to
the best alternative for the particular user, even for a
never-before-seen repository on the site. The effect of
- having multiple aka values match is undefined.
+ having multiple `insteadOf` values from different
+ `<base>` match to an URL is undefined.
user.email::
Your email address to be recorded in any newly created commits.
diff --git a/Documentation/urls.txt b/Documentation/urls.txt
index 0115af7..fa34c67 100644
--- a/Documentation/urls.txt
+++ b/Documentation/urls.txt
@@ -53,17 +53,17 @@ configuration section of the form:
------------
[url "<actual url base>"]
- aka = <other url base>
+ insteadOf = <other url base>
------------
-If you have a section:
+For example, with this:
------------
- [host "git://git.host.xz/"]
- aka = host.xz:/path/to/
- aka = work:
+ [url "git://git.host.xz/"]
+ insteadOf = host.xz:/path/to/
+ insteadOf = work:
------------
a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
-rewritten in any context that takes a URL to be
-"git://git.host.xz/repo.git".
+rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".
+
diff --git a/remote.c b/remote.c
index f8ee38e..0012954 100644
--- a/remote.c
+++ b/remote.c
@@ -4,9 +4,9 @@
struct rewrite {
const char *base;
- const char **aka;
- int aka_nr;
- int aka_alloc;
+ const char **instead_of;
+ int instead_of_nr;
+ int instead_of_alloc;
};
static struct remote **remotes;
@@ -33,13 +33,13 @@ static const char *alias_url(const char *url)
for (i = 0; i < rewrite_nr; i++) {
if (!rewrite[i])
continue;
- for (j = 0; j < rewrite[i]->aka_nr; j++) {
- if (!prefixcmp(url, rewrite[i]->aka[j])) {
+ for (j = 0; j < rewrite[i]->instead_of_nr; j++) {
+ if (!prefixcmp(url, rewrite[i]->instead_of[j])) {
char *ret = malloc(strlen(rewrite[i]->base) -
- strlen(rewrite[i]->aka[j]) +
+ strlen(rewrite[i]->instead_of[j]) +
strlen(url) + 1);
strcpy(ret, rewrite[i]->base);
- strcat(ret, url + strlen(rewrite[i]->aka[j]));
+ strcat(ret, url + strlen(rewrite[i]->instead_of[j]));
return ret;
}
}
@@ -154,10 +154,10 @@ static struct rewrite *make_rewrite(const char *base, int len)
return ret;
}
-static void add_aka(struct rewrite *rewrite, const char *aka)
+static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
{
- ALLOC_GROW(rewrite->aka, rewrite->aka_nr + 1, rewrite->aka_alloc);
- rewrite->aka[rewrite->aka_nr++] = aka;
+ ALLOC_GROW(rewrite->instead_of, rewrite->instead_of_nr + 1, rewrite->instead_of_alloc);
+ rewrite->instead_of[rewrite->instead_of_nr++] = instead_of;
}
static void read_remotes_file(struct remote *remote)
@@ -282,10 +282,10 @@ static int handle_config(const char *key, const char *value)
if (!subkey)
return 0;
rewrite = make_rewrite(name, subkey - name);
- if (!strcmp(subkey, ".aka")) {
+ if (!strcmp(subkey, ".insteadof")) {
if (!value)
return config_error_nonbool(key);
- add_aka(rewrite, xstrdup(value));
+ add_instead_of(rewrite, xstrdup(value));
}
}
if (prefixcmp(key, "remote."))
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 4ffe2a1..9023ba0 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -100,12 +100,12 @@ test_expect_success 'fetch with wildcard' '
)
'
-test_expect_success 'fetch with aka' '
+test_expect_success 'fetch with insteadOf' '
mk_empty &&
(
TRASH=$(pwd) &&
cd testrepo &&
- git config url./$TRASH/.aka trash/
+ git config url./$TRASH/.insteadOf trash/
git config remote.up.url trash/. &&
git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
git fetch up &&
@@ -143,10 +143,10 @@ test_expect_success 'push with wildcard' '
)
'
-test_expect_success 'push with aka' '
+test_expect_success 'push with insteadOf' '
mk_empty &&
TRASH=$(pwd) &&
- git config url./$TRASH/.aka trash/ &&
+ git config url./$TRASH/.insteadOf trash/ &&
git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
(
cd testrepo &&
next prev parent reply other threads:[~2008-02-25 4:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-20 18:43 [PATCH 2/2] Add support for url aliases in config files Daniel Barkalow
2008-02-20 19:15 ` Junio C Hamano
2008-02-20 19:24 ` Daniel Barkalow
2008-02-20 19:42 ` Junio C Hamano
2008-02-20 19:54 ` Jay Soffian
2008-02-20 20:42 ` Daniel Barkalow
2008-02-20 22:02 ` しらいしななこ
2008-02-20 22:22 ` Johannes Schindelin
2008-02-21 0:47 ` Junio C Hamano
2008-02-21 1:26 ` Jay Soffian
2008-02-21 1:47 ` Linus Torvalds
2008-02-21 2:19 ` Jay Soffian
2008-02-21 5:04 ` Daniel Barkalow
2008-02-21 5:34 ` Junio C Hamano
2008-02-25 4:08 ` Junio C Hamano [this message]
2008-02-25 4:30 ` Daniel Barkalow
2008-02-25 6:22 ` Junio C Hamano
2008-02-25 6:35 ` Daniel Barkalow
2008-02-21 16:31 ` Jon Loeliger
2008-02-20 19:49 ` Jay Soffian
2008-02-20 19:58 ` Junio C Hamano
2008-02-20 20:22 ` Jay Soffian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vwsotoey8.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=jaysoffian@gmail.com \
--cc=nanako3@bluebottle.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).