git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: Mathias Kunter <mathiaskunter@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: git push doesn't use local branch name as default
Date: Fri, 28 May 2021 10:44:30 -0700	[thread overview]
Message-ID: <CABPp-BEd2GAOSSAaUwMLhftiKsbFXmuszH_fXBbTY9nU=yWg9w@mail.gmail.com> (raw)
In-Reply-To: <60b126e8cf42e_51908208d4@natae.notmuch>

On Fri, May 28, 2021 at 10:22 AM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> Elijah Newren wrote:
> > > If there is no upstream, then there also is no "remote I normally pull
> > > from", and thus, according to the doc, `simple` should actually work
> > > like `current` in this case. Am I wrong here?
> >
> > The relevant code is
> >
> >     return (fetch_remote && fetch_remote != remote);
> >
> > so you only get the "current" behavior when fetch_remote is non-NULL.
>
> fetch_remote is practically never non-NULL.
>
> fetch_remote is remote_get(NULL), which is basically the equivalent of:
>
> remote_get(remote_for_branch(current_branch, ...));
>
> Typically when an upstream branch is not configured, this is the same
> as:
>
> remote_get("origin");
>
> The only time fetch_remote is NULL is when the configured remote is
> invalid.

Ah, thanks for correcting and clarifying here.

>
> So you don't get the "current" behavior when pushing to "origin".
>
> Perhaps:
>
> --- a/Documentation/config/push.txt
> +++ b/Documentation/config/push.txt
> @@ -29,8 +29,8 @@ push.default::
>    different from the local one.
>  +
>  When pushing to a remote that is different from the remote you normally
> -pull from, work as `current`.  This is the safest option and is suited
> -for beginners.
> +pull from (typically "origin"), work as `current`.  This is the safest option
> +and is suited for beginners.

This is certainly an improvement.  I wonder if it might still be
considered ambiguous or hard to parse, though.  If so, maybe something
like:

If you have a default remote configured for the current branch and are
pushing to a remote other than that one (or if you have no default
remote configured and are pushing to a remote other than 'origin'),
then work as 'current'.

It may also be helpful to move the "This is the safest option and is
suited for beginners" out of its current paragraph and combine it with
the "This mode has become the default" in the next paragraph.

  reply	other threads:[~2021-05-28 17:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3b9bc214-a30a-ba49-af96-7eeaf37b7bbd@gmail.com>
2021-05-28  6:29 ` git push doesn't use local branch name as default Mathias Kunter
2021-05-28  7:00   ` Elijah Newren
2021-05-28  7:44     ` Mathias Kunter
2021-05-28  8:51       ` Mathias Kunter
2021-05-28 21:12         ` git push default doesn't make sense Felipe Contreras
2021-05-30 16:28           ` Mathias Kunter
2021-05-30 16:32             ` Felipe Contreras
2021-05-28 17:52       ` git push doesn't use local branch name as default Felipe Contreras
2021-05-28 17:22     ` Felipe Contreras
2021-05-28 17:44       ` Elijah Newren [this message]
2021-05-28 18:58         ` Felipe Contreras
2021-05-28 17:10   ` Felipe Contreras
2021-05-27 17:06 Mathias Kunter
2021-05-27 19:51 ` Felipe Contreras

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='CABPp-BEd2GAOSSAaUwMLhftiKsbFXmuszH_fXBbTY9nU=yWg9w@mail.gmail.com' \
    --to=newren@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mathiaskunter@gmail.com \
    /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 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).