Re: [PATCH] push: Alias pushurl from push rewrites
- From
Rob Hoelz <rob@hoelz.ro>
- Date
- Mar 27, 2013, 22:29 UTC
- Message-ID
- <20130327172909.532a30b6@hoelz.ro>
- In-Reply-To
- <20130327182345.GD28148@google.com>
On Wed, 27 Mar 2013 11:23:45 -0700 Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 31 quoted lines
> Rob Hoelz wrote:
>
> > --- a/remote.c
> > +++ b/remote.c
> > @@ -465,7 +465,11 @@ static void alias_all_urls(void)
> > if (!remotes[i])
> > continue;
> > for (j = 0; j < remotes[i]->pushurl_nr; j++) {
> > - remotes[i]->pushurl[j] =
> > alias_url(remotes[i]->pushurl[j], &rewrites);
> > + char *copy =
> > xstrdup(remotes[i]->pushurl[j]);
> > + remotes[i]->pushurl[j] =
> > alias_url(remotes[i]->pushurl[j], &rewrites_push);
> > + if (!strcmp(copy, remotes[i]->pushurl[j]))
> > + remotes[i]->pushurl[j] =
> > alias_url(remotes[i]->pushurl[j], &rewrites);
> > + free(copy);
>
> Interesting.
>
> Suppose I configure
>
> [url "git://anongit.myserver.example.com/"]
> insteadOf = myserver.example.com:
> [url "myserver:"]
> pushInsteadOf = myserver.example.com:
>
> The above code would make the insteadOf rule apply instead of
> pushInsteadOf, even when pushing. Perhaps something like the
> following would work?Are you sure? I create a copy, and compare the copy to the new URL. If they're the same (pushInsteadOf not found), I then use the insteadOf mapping to perform the alteration. Did I introduce a bug?