threads / rfc / 40972

[RFC] Case insensitive URL rewrite

Subject: [RFC] Case insensitive URL rewrite

## tl;dr

6 messages between Dec 11, 2015 and Dec 11, 2015.

replies: 5people: 5as markdown or json

Lars Schneider· Dec 11, 2015, 13:45 UTC · lore
Hi,
the "url.<someURL>.insteadOf" git config is case sensitive. I understand that this makes sense on case sensitive file systems. However, URLs are mostly case insensitive:

Consider this: git clone https://GIThub.com/GIT/GIT git clone https://github.com/git/git

Both commands will clone the same repository.

Interestingly enough this works, too: git clone git@GIThub.com:GIT/GIT

What do you think about a flag that makes these rewrites case insensitive? E.g. with the following config flag:
[url "<actual url base>"]
	insteadOf = <other url base>
	ignorecase = true

Thanks, Lars

Daniel Stenberg· Dec 11, 2015, 14:38 UTC · re: Lars Schneider · lore

Re: [RFC] Case insensitive URL rewrite

On Fri, 11 Dec 2015, Lars Schneider wrote:
> the "url.<someURL>.insteadOf" git config is case sensitive. I understand 
> that this makes sense on case sensitive file systems. However, URLs are 
> mostly case insensitive:
Minor detail here perhaps, but...

I would object to URLs being "mostly case insensitive", even if github apparently seems to work that way. The path part of URLs are rarely case insensitive since it tends to map to a *nix file system, while the host name part is insensitive as section 3.2.2 in RFC 3986 says.

-- 
  / daniel.haxx.se
Junio C Hamano· Dec 11, 2015, 18:26 UTC · re: Lars Schneider · lore

Re: [RFC] Case insensitive URL rewrite

Lars Schneider <larsxschneider@gmail.com> writes:
Show 5 quoted lines
> What do you think about a flag that makes these rewrites case insensitive? E.g. with the following config flag:
>
> [url "<actual url base>"]
> 	insteadOf = <other url base>
> 	ignorecase = true
I am with Daniel on this.
It is perfectly fine to consider these two equivalent.
    git clone https://github.com/git/git (canonical one)
    git clone https://GitHub.com/git/git (host part in funny case)

In fact, I think we should do this without any additional configuration variable.

On the other hand, these two MUST be treated as different by default:

    git clone https://github.com/GIT/GIT (differences outside host part)
    git clone git@github.com:GIT/GIT     (differences outside host part)

Although I am OK if this is hidden behind a configuration variable, I am not sure how much value you would be giving to the users.

In any case, I expect that additional change (on top of what is required to make hostname part treated case insensitively) would not be too bad, if we were going to fix the hostname part.

Stefan Beller· Dec 11, 2015, 18:51 UTC · re: Junio C Hamano · lore

Re: [RFC] Case insensitive URL rewrite

On Fri, Dec 11, 2015 at 10:26 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 5 quoted lines
> On the other hand, these two MUST be treated as different by
> default:
>
>     git clone https://github.com/GIT/GIT (differences outside host part)
>     git clone git@github.com:GIT/GIT     (differences outside host part)

This is one of the more obvious examples I would think as the protocol is different. What about:

     git clone git@example.com:git/git     (differences outside host part)
     git clone git@example.com:GIT/GIT     (differences outside host part)

If the host has a filesystem which respects capitalization, these may be two different repositories.

Junio C Hamano· Dec 11, 2015, 18:56 UTC · re: Stefan Beller · lore

Re: [RFC] Case insensitive URL rewrite

Stefan Beller <sbeller@google.com> writes:
Show 9 quoted lines
> On Fri, Dec 11, 2015 at 10:26 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> On the other hand, these two MUST be treated as different by
>> default:
>>
>>     git clone https://github.com/GIT/GIT (differences outside host part)
>>     git clone git@github.com:GIT/GIT     (differences outside host part)
>
> This is one of the more obvious examples I would think as the protocol is
> different.

Oh, I should have been more careful; I did not think Lars meant git@GitHub.com should somehow match https://github.com but a more obvious "git@github.com:GIT/GIT and git@GitHub.com:git/git behave the same", and I thought everybody who read it understood the example as such.

Show 7 quoted lines
> What about:
>
>      git clone git@example.com:git/git     (differences outside host part)
>      git clone git@example.com:GIT/GIT     (differences outside host part)
>
> If the host has a filesystem which respects capitalization, these may be
> two different repositories.
That is what I meant.  Thanks for clarification.
Jeff King· Dec 11, 2015, 19:15 UTC · re: Junio C Hamano · lore

Re: [RFC] Case insensitive URL rewrite

On Fri, Dec 11, 2015 at 10:26:41AM -0800, Junio C Hamano wrote:
Show 23 quoted lines
> Lars Schneider <larsxschneider@gmail.com> writes:
> 
> > What do you think about a flag that makes these rewrites case insensitive? E.g. with the following config flag:
> >
> > [url "<actual url base>"]
> > 	insteadOf = <other url base>
> > 	ignorecase = true
> 
> I am with Daniel on this.
> 
> It is perfectly fine to consider these two equivalent.
> 
>     git clone https://github.com/git/git (canonical one)
>     git clone https://GitHub.com/git/git (host part in funny case)
> 
> In fact, I think we should do this without any additional
> configuration variable.
> 
> On the other hand, these two MUST be treated as different by
> default:
> 
>     git clone https://github.com/GIT/GIT (differences outside host part)
>     git clone git@github.com:GIT/GIT     (differences outside host part)

I haven't looked, but the code in urlmatch.c probably gets all of this right already. It was written much later than the insteadOf code, as it was part of the http.$url.* matching, and it may be reasonable to simply teach the insteadOf code to use it. OTOH, it may need tweaked because I'm not sure how it would handle non-URLs like the "host:path" ssh form.

-Peff

← back to recent threads