All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Alexander Duytschaever <Alexander.Duytschaever@UGent.be>
Cc: "git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: rename a remote does not update pushdefault (v1.9.5)
Date: Mon, 30 Mar 2015 12:39:17 -0700	[thread overview]
Message-ID: <xmqq384mxoka.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <B2C5B27F9C4A45469123297E3F6BCF0C55DA0AEA07@XMAIL08.UGent.be> (Alexander Duytschaever's message of "Mon, 30 Mar 2015 11:28:30 +0200")

Alexander Duytschaever <Alexander.Duytschaever@UGent.be> writes:

> When defining pushdefault and renaming the associated remote, the
> pushdefault setting becomes invalid. Instead, it should follow the
> renamed remote if that was designated as pushdefault.
>
> Test procedure:
>
> 1. Create/cd empty directory
> 2. `git init .`
> 3. `git remote add abc def`
> 4. Observe that `git remote` now shows 'abc'
> 5. `git config default.pushdefault abc`
> 6. Observe that `git config --list` shows default.pushdefault=abc

I do not think we have default.pushdefault.  Perhaps you meant
remote.pushdefault, but even then, I do not think we usually set
that up by default.

> 7. `git remote rename abc xyz`
>
> BUG: observe that pushdefault still refers to 'abc', while it should now refer to 'xyz'.

Again,  by default remote.pushDefault is not set up by us, so there
is nothing to comment here.

> (Initially (wrongly) filed as TGit bug:

Perhaps TGit is setting remote.pushDefault?  If so, I would say a
bug (if there is a bug, which I highly doubt; see below) belongs
there.

Having said all that, if you did this instead, you will see that
remote.pushdefault will not change:

    $ git init
    $ git remote add abc def
    $ git config remote.pushdefault abc
    $ git config remote.pushdefault
    abc
    $ git remote rename abc xyz
    $ git config remote.pushdefault
    abc

and I can see this argued both ways.

1. Imagine you so far had three remotes A, B and DEFAULT defined,
   among which the last one was the default push destination, like
   this:

       [remote]
           pushDefault = DEFAULT
       [remote "A"]
           url = http://a.xz/project
       [remote "B"]
           url = http://b.xz/project
       [remote "DEFAULT"]
           url = http://c.xz/project

   and for whatever reason, you decided c.xz should not be the default
   place for you to push to, but instead you want to make b.xz the
   default.  It is conceivable that you would expect this to work:

       $ git remote rename DEFAULT C
       $ git remote rename B DEFAULT
    
   to give you this:

       [remote]
           pushDefault = DEFAULT
       [remote "A"]
           url = http://a.xz/project
       [remote "DEFAULT"]
           url = http://b.xz/project
       [remote "C"]
           url = http://c.xz/project

   And for that use case, remaing remote.pushDefault is absolutely the
   wrong thing to do.  After the "rename DEFAULT C", remote.pushDefault
   must not be moved to C, because the next "rename B DEFAULT" will not
   be able to guess that remote.pushDefault wants to become DEFAULT.

2. On the other hand, starting from the same "A, B and DEFAULT"
   state, you may be trying to rename DEFAULT everywhere to C to
   come to this instead:

       [remote]
           pushDefault = C
       [remote "A"]
           url = http://a.xz/project
       [remote "B"]
           url = http://b.xz/project
       [remote "C"]
           url = http://c.xz/project

   And for that use case, not remaing remote.pushDefault will appear to
   be a bug, as remote.pushDefault will be left as DEFAULT.

Whichever way you implement "remote rename", you will make half of
the users happy while making other half unhappy.  One use case will
be happier if remote.pushdefault is left intact; the other use case
will be happier if remote.pushdefault is updated.  There are two
sides to this coin.

I think the implementation took the most straight-forward path to
say "we rename everything inside remote.C.* section and adjust the
refspecs for remote-tracking branches because that is what appear in
that section"; which allows the first use case and the second use
case would be just a single "git config remote.pushDefault C" away.

If you change what the command does this late in the game, then not
only you will upset people who have been happy with the current
behaviour (mostly those who used the first scenario), but you will
not really help people who may have wished that remote.pushDefault
to be adjusted either, because they are already used to do the final
"git config remote.pushDefault C" anyway.

So...

  reply	other threads:[~2015-03-30 19:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30  9:28 rename a remote does not update pushdefault (v1.9.5) Alexander Duytschaever
2015-03-30 19:39 ` Junio C Hamano [this message]
2015-03-31  3:52   ` Jeff King

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

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

  git send-email \
    --in-reply-to=xmqq384mxoka.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Alexander.Duytschaever@UGent.be \
    --cc=git@vger.kernel.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.
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.