All of lore.kernel.org
 help / color / mirror / Atom feed
* URL rewrite in local config unable to override global config rule
@ 2016-06-16 10:14 Saksham Saxena
  2016-06-16 12:13 ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Saksham Saxena @ 2016-06-16 10:14 UTC (permalink / raw)
  To: git

Hello everyone

I came across an anomaly in git recently, and would like to share it
here. Please suggest if this is a bug, or if my approach is wrong.

Summary : Added a new rule to the local config of a git repo by
issuing ' git config --local url."https://".insteadOf git:// ', but it
wasn't observed by git as it kept using "git://".

Details : I had set my global config to use "git://" instead of
"https://", as I prefer working with SSH. Recently, I began writing a
'GitHub Wiki' of one of my GitHub projects, and, apparently, those
Wikis are normal git repositories, and can be cloned and edited
locally. However, the clone url available is served over HTTPS only,
and doesn't support any other protocol. Naturally, I had to change my
config to change the behavior of git while connecting to the remote. I
thus proceeded to update the local config of the repo to use
"https://" instead of "git://". However, my remote urls weren't
updated. I manually then removed these remote urls and added new HTTPS
ones. Yet, the remote urls showed "git://" protocol in them.
Screenshot of the terminal window can be found here
(http://i.stack.imgur.com/y7GMP.png).

I tried to add the "pushInsteadOf" rule as well, but again, it didn't
take effect. This is particularly disappointing, because the local
config have the highest priority, and yet it isn't effective at all.
Because of the limitation of my remote, I cannot even push my changes.
True, that I can dig up some dirty workarounds, but I do not
understand why this behavior is seen.

I have also asked this on the popular Stack Overflow forum
(http://stackoverflow.com/questions/37844460/git-remote-url-is-not-updating).
If any of the moderators here do not find this issue as a bug, then
they may help me out on the forum itself (if you happen to be on it)
to reduce the noise on this thread.

I hope I described my problem clearly. Awaiting response.

Regards
Saksham Saxena

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: URL rewrite in local config unable to override global config rule
  2016-06-16 10:14 URL rewrite in local config unable to override global config rule Saksham Saxena
@ 2016-06-16 12:13 ` Jeff King
  2016-06-17 14:35   ` Saksham Saxena
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2016-06-16 12:13 UTC (permalink / raw)
  To: Saksham Saxena; +Cc: git

On Thu, Jun 16, 2016 at 03:44:17PM +0530, Saksham Saxena wrote:

> Summary : Added a new rule to the local config of a git repo by
> issuing ' git config --local url."https://".insteadOf git:// ', but it
> wasn't observed by git as it kept using "git://".

Hmm. This works in a simple example for me...

> Details : I had set my global config to use "git://" instead of
> "https://", as I prefer working with SSH.

..even if I have an existing "url.git://.insteadOf=https://". But I
could believe that having other config confuses things. The
url-rewriting is not "last one wins", but rather that we try all of
them, and the longest match wins.

Can you show us the output of "git config --list" on a repository that
is having this problem, and then the command that you run and its
output?

> Recently, I began writing a
> 'GitHub Wiki' of one of my GitHub projects, and, apparently, those
> Wikis are normal git repositories, and can be cloned and edited
> locally. However, the clone url available is served over HTTPS only,
> and doesn't support any other protocol.

You should be able to clone, fetch, or push wiki repositories using any
of the normal protocols. So:

  git@github.com:username/repo.wiki.git

should work. Likewise, git:// will work if the repository is public, but
you cannot push over it.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: URL rewrite in local config unable to override global config rule
  2016-06-16 12:13 ` Jeff King
@ 2016-06-17 14:35   ` Saksham Saxena
  2016-06-17 15:01     ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Saksham Saxena @ 2016-06-17 14:35 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Thu, Jun 16, 2016 at 5:43 PM, Jeff King <peff@peff.net> wrote:
> On Thu, Jun 16, 2016 at 03:44:17PM +0530, Saksham Saxena wrote:
>
>> Summary : Added a new rule to the local config of a git repo by
>> issuing ' git config --local url."https://".insteadOf git:// ', but it
>> wasn't observed by git as it kept using "git://".
>
> Hmm. This works in a simple example for me...
>
>> Details : I had set my global config to use "git://" instead of
>> "https://", as I prefer working with SSH.
>
> ..even if I have an existing "url.git://.insteadOf=https://". But I
> could believe that having other config confuses things. The
> url-rewriting is not "last one wins", but rather that we try all of
>
> > them, and the longest match wins.

Longest? Could you elaborate please?

>
> Can you show us the output of "git config --list" on a repository that
> is having this problem, and then the command that you run and its
>
> > output?

Here you go (https://gist.github.com/sakshamsaxena/a1cee9c39ddc127ae659e92d02d58f0b).
The commands are run in that sequence.

>
>> Recently, I began writing a
>> 'GitHub Wiki' of one of my GitHub projects, and, apparently, those
>> Wikis are normal git repositories, and can be cloned and edited
>> locally. However, the clone url available is served over HTTPS only,
>> and doesn't support any other protocol.
>
> You should be able to clone, fetch, or push wiki repositories using any
> of the normal protocols. So:
>
>   git@github.com:username/repo.wiki.git
>
> should work. Likewise, git:// will work if the repository is public, but
>
> > you cannot push over it.

True. Can't push over git:// and that's why I'm limited to https://

>
> -Peff



-- 
Regards
Saksham Saxena
Member, IEEE Delhi Section Student Network
Member, IEEE DTU Student Branch
Student, Delhi Technological University

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: URL rewrite in local config unable to override global config rule
  2016-06-17 14:35   ` Saksham Saxena
@ 2016-06-17 15:01     ` Jeff King
  2016-06-18  5:36       ` Saksham Saxena
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2016-06-17 15:01 UTC (permalink / raw)
  To: Saksham Saxena; +Cc: git

On Fri, Jun 17, 2016 at 08:05:47PM +0530, Saksham Saxena wrote:

> > ..even if I have an existing "url.git://.insteadOf=https://". But I
> > could believe that having other config confuses things. The
> > url-rewriting is not "last one wins", but rather that we try all of
> >
> > > them, and the longest match wins.
> 
> Longest? Could you elaborate please?

The one that matches the longest number of characters. So
"https://example.com" is a preferred match over "https://".

I don't think that's what's going on here, though.

> Here you go (https://gist.github.com/sakshamsaxena/a1cee9c39ddc127ae659e92d02d58f0b).
> The commands are run in that sequence.

OK, so you have:

  url.git://.insteadof=https://

in your initial config, to convert https URLs to git.

Later you add:

  url.https://.insteadof=git://

to do the opposite.

The URL in your config uses http:

  remote.origin.url=https://github.com/sakshamsaxena/sails-hook-jbvcs.wiki.git

And when you push, this gets converted to "git://".

I think this is the expected behavior, due to the first insteadOf, which
converts https to git. Both rules are "active", in the sense that the
later one does not replace the former; together they make a list of
rules to try applying.

Git doesn't recursively apply insteadOf transformations. So the "convert
https to git" rule triggers, and we stop. The "convert git to https" one
doesn't trigger initially (because we are already https). And if we were
to apply rules recursively in this case, it would loop infinitely.

So I this is all operating as intended. And what you really want is a
way to say "erase any earlier rewrite rules; I do not want them applied
in this repository". There's currently not any way to do that.

For other "multi-valued configs" like this one (i.e., ones that form a
list rather than overriding earlier values), we have started using the
convention that assigning the empty value resets the list. But this
particular config key has not learned that trick yet, so it would
require a patch to git.

> > You should be able to clone, fetch, or push wiki repositories using any
> > of the normal protocols. So:
> >
> >   git@github.com:username/repo.wiki.git
> >
> > should work. Likewise, git:// will work if the repository is public, but
> >
> > > you cannot push over it.
> 
> True. Can't push over git:// and that's why I'm limited to https://

You can over ssh, though (which I thought you said earlier was your
preferred protocol).

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: URL rewrite in local config unable to override global config rule
  2016-06-17 15:01     ` Jeff King
@ 2016-06-18  5:36       ` Saksham Saxena
  2016-06-18 13:49         ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Saksham Saxena @ 2016-06-18  5:36 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Thanks a lot Peff. This cleared a lot of things. Would it be okay if I
cite some parts of this conversation on my personal blog?

On Fri, Jun 17, 2016 at 8:31 PM, Jeff King <peff@peff.net> wrote:
> On Fri, Jun 17, 2016 at 08:05:47PM +0530, Saksham Saxena wrote:
>
>> > ..even if I have an existing "url.git://.insteadOf=https://". But I
>> > could believe that having other config confuses things. The
>> > url-rewriting is not "last one wins", but rather that we try all of
>> >
>> > > them, and the longest match wins.
>>
>> Longest? Could you elaborate please?
>
> The one that matches the longest number of characters. So
> "https://example.com" is a preferred match over "https://".
>
> I don't think that's what's going on here, though.
>
>> Here you go (https://gist.github.com/sakshamsaxena/a1cee9c39ddc127ae659e92d02d58f0b).
>> The commands are run in that sequence.
>
> OK, so you have:
>
>   url.git://.insteadof=https://
>
> in your initial config, to convert https URLs to git.
>
> Later you add:
>
>   url.https://.insteadof=git://
>
> to do the opposite.
>
> The URL in your config uses http:
>
>   remote.origin.url=https://github.com/sakshamsaxena/sails-hook-jbvcs.wiki.git
>
> And when you push, this gets converted to "git://".
>
> I think this is the expected behavior, due to the first insteadOf, which
> converts https to git. Both rules are "active", in the sense that the
> later one does not replace the former; together they make a list of
> rules to try applying.
>
> Git doesn't recursively apply insteadOf transformations. So the "convert
> https to git" rule triggers, and we stop. The "convert git to https" one
> doesn't trigger initially (because we are already https). And if we were
> to apply rules recursively in this case, it would loop infinitely.
>
> So I this is all operating as intended. And what you really want is a
> way to say "erase any earlier rewrite rules; I do not want them applied
> in this repository". There's currently not any way to do that.
>
> For other "multi-valued configs" like this one (i.e., ones that form a
> list rather than overriding earlier values), we have started using the
> convention that assigning the empty value resets the list. But this
> particular config key has not learned that trick yet, so it would
> require a patch to git.
>
>> > You should be able to clone, fetch, or push wiki repositories using any
>> > of the normal protocols. So:
>> >
>> >   git@github.com:username/repo.wiki.git
>> >
>> > should work. Likewise, git:// will work if the repository is public, but
>> >
>> > > you cannot push over it.
>>
>> True. Can't push over git:// and that's why I'm limited to https://
>
> You can over ssh, though (which I thought you said earlier was your
> preferred protocol).
>
> -Peff

Thanks and Regards
Saksham Saxena

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: URL rewrite in local config unable to override global config rule
  2016-06-18  5:36       ` Saksham Saxena
@ 2016-06-18 13:49         ` Jeff King
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2016-06-18 13:49 UTC (permalink / raw)
  To: Saksham Saxena; +Cc: git

On Sat, Jun 18, 2016 at 11:06:41AM +0530, Saksham Saxena wrote:

> Thanks a lot Peff. This cleared a lot of things. Would it be okay if I
> cite some parts of this conversation on my personal blog?

Sure, that is fine with me.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-18 13:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16 10:14 URL rewrite in local config unable to override global config rule Saksham Saxena
2016-06-16 12:13 ` Jeff King
2016-06-17 14:35   ` Saksham Saxena
2016-06-17 15:01     ` Jeff King
2016-06-18  5:36       ` Saksham Saxena
2016-06-18 13:49         ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.