git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Jardel Weyrich <jweyrich@gmail.com>
Cc: Sascha Cunz <sascha-ml@babbelbox.org>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org
Subject: Re: [BUG] Possible bug in `remote set-url --add --push`
Date: Mon, 14 Jan 2013 14:07:34 +0100	[thread overview]
Message-ID: <50F40316.7010308@drmicha.warpmail.net> (raw)
In-Reply-To: <CAN8TAOv0Cm8CgiJSweFtRzOqO78OtNKa4G+x7z6M5Bt+odUmiQ@mail.gmail.com>

Jardel Weyrich venit, vidit, dixit 12.01.2013 10:33:
> On Sat, Jan 12, 2013 at 6:44 AM, Sascha Cunz <sascha-ml@babbelbox.org> wrote:
>> Am Freitag, 11. Januar 2013, 23:10:36 schrieb Junio C Hamano:
>>> 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?
> 
> You're right. However, as I quoted earlier, the git-remote man-page states:
> 
>        set-url
>            Changes URL remote points to. <suppressed>
>            With --push, push URLs are manipulated instead of fetch URLs.
>            With --add, instead of changing some URL, new URL is added.
> 
> It explicitly mentions that it should **add a new URL**.
> So when I do `git remote set-url --add --push origin
> git://another/repo.git`, I expect git-push to use both the default
> push URL and the new one. Or am I misinterpreting the man-page?
> 
>>
>> 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.
> 
> Correct. Adding a remote doesn't automatically generate a pushurl for it.
> 
> To me, it seems that git-push checks for the existence of pushurl's in
> the config, and if it finds any, it ignores the defaul push URL during
> the actual push. In better words, it pushes only to pushurls, if it
> finds any, otherwise it pushes to the default URL.
> 
> To comply with the statements in the git-remote man-page, git-remote
> should add a pushurl configuration containing the default push URL,
> along with the one passed to `set-url --add --push`. Or git-push
> should _not ignore_ the default URL in the presence of pushurls,
> effectively pushing to both. These are the solutions I can think of
> right now, supposing I'm correct about the cause(s).
> 
>>
>> Sascha

All that "set-url --push --add" does is adding a remote.foo.pushurl
entry to the config. If there was none, there will be one after that.

If there is no pushurl entry, "push" takes the url entry instead. This
is the "default URL for push", but not a pushurl entry.

It seems to me that everything works as designed, and that the man page
talk about "push URLs" can be read in two ways, one of which is correct
(and which is obvious if you know the above, i.e. the "config
background") and one of which is incorrect (and which may be obvious if
you read just that man page paragraph).

Michael

  reply	other threads:[~2013-01-14 13:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-12  5:44 [BUG] Possible bug in `remote set-url --add --push` Jardel Weyrich
2013-01-12  7:10 ` Junio C Hamano
2013-01-12  8:09   ` Jardel Weyrich
2013-01-12  8:23     ` Junio C Hamano
2013-01-12  8:44   ` Sascha Cunz
2013-01-12  9:33     ` Jardel Weyrich
2013-01-14 13:07       ` Michael J Gruber [this message]
2013-01-14 16:41         ` Jonathan Nieder
2013-01-14 19:09         ` Junio C Hamano
2013-01-15  5:20           ` Jardel Weyrich
2013-01-15  6:22             ` Junio C Hamano
2013-01-15  6:39               ` Junio C Hamano
2013-01-15  9:44                 ` Michael J Gruber
2013-01-15 15:53                   ` Junio C Hamano
2013-01-16  8:46                     ` Michael J Gruber
2013-01-16 15:50                       ` Junio C Hamano
2013-01-16 16:19                         ` Michael J Gruber
2013-01-16 19:30                         ` Andreas Schwab
2013-01-16 20:01                           ` Junio C Hamano
2013-01-16 10:14                     ` [PATCH] git-remote: distinguish between default and configured URLs Michael J Gruber
2013-01-16 10:27                       ` Michael J Gruber
2013-01-16 10:42                       ` John Keeping
2013-01-16 12:45                         ` Michael J Gruber
2013-01-16 13:04                           ` John Keeping
2013-01-16 19:19                           ` Junio C Hamano
2013-01-16 16:15                     ` [BUG] Possible bug in `remote set-url --add --push` Phil Hord
2013-01-16 16:24                       ` Michael J Gruber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F40316.7010308@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jweyrich@gmail.com \
    --cc=sascha-ml@babbelbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).