git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] Possible bug in `remote set-url --add --push`

From
SCSascha Cunz <sascha-ml@babbelbox.org>
Date
Jan 12, 2013, 08:44 UTC
Message-ID
<4836187.09xoy3kJnj@blacky>
In-Reply-To
<7vliby98r7.fsf@alter.siamese.dyndns.org>
Am Freitag, 11. Januar 2013, 23:10:36 schrieb Junio C Hamano:
Show 50 quoted lines
> Jardel Weyrich <jweyrich@gmail.com> writes:
> > I believe `remote set-url --add --push` has a bug. Performed tests
> > with v1.8.0.1 and v1.8.1 (Mac OS X).
> > 
> > Quoting the relevant part of the documentation:
> >> set-url
> >> 
> >>     Changes URL remote points to. Sets first URL remote points to
> >>     matching regex <oldurl> (first URL if no <oldurl> is given) to
> >>     <newurl>. If <oldurl> doesn’t match any URL, error occurs and
> >>     nothing is changed.
> >>     
> >>     With --push, push URLs are manipulated instead of fetch URLs.
> >>     With --add, instead of changing some URL, new URL is added.
> >>     With --delete, instead of changing some URL, all URLs matching regex
> >>     <url> are deleted. Trying to delete all non-push URLs is an error.> 
> > Here are some steps to reproduce:
> > 
> > 1. Show the remote URLs
> > 
> > jweyrich@pharao:test_clone1 [* master]$ git remote -v
> > origin  /Volumes/sandbox/test (fetch)
> > origin  /Volumes/sandbox/test (push)
> > 
> > 2. Add a new push URL for origin
> > 
> > jweyrich@pharao:test_clone1 [* master]$ git remote set-url --add --push
> > origin \> 
> >     /Volumes/sandbox/test_clone2
> > 
> > 3. Check what happened
> > 
> > jweyrich@pharao:test_clone1 [* master]$ git remote -v
> > origin  /Volumes/sandbox/test (fetch)
> > origin  /Volumes/sandbox/test_clone2 (push)
> 
> The original pushurl was replaced with the additional one, instead
> of being left and the new one getting added.  That looks certainly
> wrong.
> 
> However, the result of applying the attached patch (either to
> v1.7.12 or v1.8.1) still passes the test and I do not think it is
> doing anything differently from what you described above.
> 
> What do you get from
> 
> 	git config -l | grep '^remote\.origin'
> 
> in steps 1. and 3. in your procedure?  This question is trying to
> tell if your bug is in "git remote -v" or in "git remote set-url".
I'm not sure, if there is a bug at all. According to man git-push:
	The <pushurl> is used for pushes only. It is optional and defaults to
   <url>.
	(From the section REMOTES -> Named remote in configuration file)
the command:
    git remote add foo git@foo-fetch.org/some.git

will set "remote.foo.url" to "git@foo-fetch.org". Subsequently, fetch and push will use git@foo-fetch.org as url. Fetch will use this url, because "remote.foo.url" explicitly sets this. push will use it in absence of a "remote.foo.pushurl".

Now, we're adding a push-url:
    git remote set-url --add --push foo git@foo-push.org/some.git
Relevant parts of config are now looking like:
	[remote "foo"]
        url = git@foo-fetch.org/some.git
        pushurl = git@foo-push.org/some.git

Since, pushurl is now given explicitly, git push will use that one (and only that one).

If we add another push-url now,
    git remote set-url --add --push foo git@foo-push-also.org/some.git
the next git-push will push to foo-push.org and foo-push-also.org.

Now, using --set-url --delete on both of these urls restores the original state: only "remote.foo.url" is set; meaning implicitly pushurl defaults to url again.

To me this is exactly what Jardel was observing:
> In step 2, Git replaced the original push URL instead of adding a new
> one. But it seems to happen only the first time I use `remote set-url
> --add --push`. Re-adding the original URL using the same command seems
> to work properly.
> And FWIW, if I delete (with "set-url --delete") both URLs push, Git
> restores the original URL.
Or am I missing something here?
Might be that the "bug" actually is that the expectation was
	git remote add foo git@foo-fetch.org/some.git
should have created a config like:
	[remote "foo"]
        url = git@foo-fetch.org/some.git
        pushurl = git@foo-fetch.org/some.git
since that is what "git remote -v" reports.

If that is the case, we might want to amend the output of 'git remote -v' with the information that a pushurl is not explicitly given and thus defaults to url.

Sascha
Previous: Junio C HamanoNext: Jardel Weyrich
Message 5 of 27 in “[BUG] Possible bug in `remote set-url --add --push`”
  1. Jardel WeyrichJan 12, 2013
  2. Junio C HamanoJan 12, 2013
  3. Jardel WeyrichJan 12, 2013
  4. Junio C HamanoJan 12, 2013
  5. Sascha CunzJan 12, 2013
  6. Jardel WeyrichJan 12, 2013
  7. Michael J GruberJan 14, 2013
  8. Jonathan NiederJan 14, 2013
  9. Junio C HamanoJan 14, 2013
  10. Jardel WeyrichJan 15, 2013
  11. Junio C HamanoJan 15, 2013
  12. Junio C HamanoJan 15, 2013
  13. Michael J GruberJan 15, 2013
  14. Junio C HamanoJan 15, 2013
  15. Michael J GruberJan 16, 2013
  16. Junio C HamanoJan 16, 2013
  17. Michael J GruberJan 16, 2013
  18. Andreas SchwabJan 16, 2013
  19. Junio C HamanoJan 16, 2013
  20. git-remote: distinguish between default and configured URLsMichael J Gruber, Jan 16, 2013
  21. Michael J GruberJan 16, 2013
  22. John KeepingJan 16, 2013
  23. Michael J GruberJan 16, 2013
  24. John KeepingJan 16, 2013
  25. Junio C HamanoJan 16, 2013
  26. Phil HordJan 16, 2013
  27. Michael J GruberJan 16, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.