Subject: Re: Potential problems with url.<base>.insteadOf

From: Junio C Hamano <[email-masked]>
Date: Fri, 26 Aug 2022 09:13:27 -0700

Javier Mora <[email-masked]> writes:

> The choice of `url.<replacement>.insteadOf <original>` as a way to
> replace URLs is not only a bit confusing, as it has already been
> discussed[1], but also presents some problems and makes it impossible
> to achieve certain configurations.
> [1] https://public-inbox.org/git/[email-masked]/
>
> SCENARIO 1:
> I want to replace all references to the (now defunct)
> 'http://example.org/' to the new server, 'http://example.com/'.
>
> OK, that is easy (even if a bit counter-intuitive).  Just do:
> git config url.'http://example.com/'.insteadOf 'http://example.org/'
>
> SCENARIO 2:
> I want to replace BOTH 'http://example.org/' and 'http://example.net/'
> with 'http://example.com/'.

So, you want to end up with

    [url "http://example.com/"]
	insteadOf = http://example.org
	insteadOf = http://example.net

but you cannot get there with only "git config VARIABLE VALUE",
because that syntax is used to clear the existing values for
VARIRABLE before setting it to VALUE.

Have you tried

    $ git config url.http://example.com/.insteadof http://example.org

that clears existing values for url.http://example.com/.insteadof
and sets it to "http://example.org", then immediately follow it with

    $ git config --add url.http://example.com/.insteadof http://example.net

that keeps existing values for url.http://example.com/.insteadof
and adds another value to the same variable?