git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bugreport: git push disobeys -c remote.xxx.url=...
@ 2014-05-30  0:03 fuz
  2014-05-30  1:43 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: fuz @ 2014-05-30  0:03 UTC (permalink / raw)
  To: git

Hello!

I've tried to changing the URL of a remote temporarily because of network
issues. I tried something like this:

    git -c remote.foo.url=http://gitserver.example/repo.git push foo bar

Tracing shows that git push does not use the provided URL for the remote foo
and instead uses the URL configured in the repository configuration as if the
-c option was not present at all. This looks like a bug to me.

My git identifies as version 1.8.1.2.

Yours sincerely,
Robert Clausecker

-- 
()  ascii ribbon campaign - for an 8-bit clean world 
/\  - against html email  - against proprietary attachments

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

* Re: Bugreport: git push disobeys -c remote.xxx.url=...
  2014-05-30  0:03 Bugreport: git push disobeys -c remote.xxx.url= fuz
@ 2014-05-30  1:43 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2014-05-30  1:43 UTC (permalink / raw)
  To: fuz; +Cc: git

On Fri, May 30, 2014 at 02:03:56AM +0200, fuz@fuz.su wrote:

> I've tried to changing the URL of a remote temporarily because of network
> issues. I tried something like this:
> 
>     git -c remote.foo.url=http://gitserver.example/repo.git push foo bar
> 
> Tracing shows that git push does not use the provided URL for the remote foo
> and instead uses the URL configured in the repository configuration as if the
> -c option was not present at all. This looks like a bug to me.

You are correct that this won't work, but the reason is a bit
complicated.

The remote.*.url config field is actually a "multivar", meaning that you
can specify it multiple times. In that case, "git push" will push to
each configured URL in order in which they appear in the config.

In the command above you are not overwriting remote.foo.url, but rather
adding an extra value to it. So we first try to push to the remote
defined in your actual config, and then to the one on the command-line.
You can see this in action like:

  $ git init --bare /tmp/foo
  $ git init --bare /tmp/bar
  $ git remote add foo /tmp/foo
  $ git -c remote.foo.url=/tmp/bar push foo HEAD

You should see pushes to both /tmp/foo and /tmp/bar.

Config multivars like this are rather hard to work with, as there is no
way to say "reset the multivar to empty, _then_ add this new value". So
there isn't a simple solution using remote.*.url from the command-line
like this.

Another way of doing what you want is to use url.*.insteadOf, like:

   git -c url./tmp/bar.insteadof=/tmp/foo push foo HEAD

-Peff

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

end of thread, other threads:[~2014-05-30  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-30  0:03 Bugreport: git push disobeys -c remote.xxx.url= fuz
2014-05-30  1:43 ` Jeff King

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).