git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tao Klerks <tao@klerks.biz>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Josh Steadmon" <steadmon@google.com>,
	"Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com>,
	git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>
Subject: Re: [PATCH v4] merge: new autosetupmerge option 'simple' for matching branches
Date: Wed, 20 Apr 2022 23:31:57 +0200	[thread overview]
Message-ID: <CAPMMpohQei9vBBm=7hC=N5LPwzMCED=fZcXyePnrkLCHfCJTZw@mail.gmail.com> (raw)
In-Reply-To: <xmqqczhbr6pv.fsf@gitster.g>

On Wed, Apr 20, 2022 at 7:43 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Tao Klerks <tao@klerks.biz> writes:
>
> > ...
> > To choose either option permanently, see push.default in 'git help config'.
> > ---
> >
> > I would propose to add one sentence at the end along the lines of:
> > ---
> > To instead avoid automatically configuring upstream branches when
> > their name doesn't match the local branch, see option 'simple' of
> > branch.autosetupmerge in 'git help config'.
> > ---
> >
> > Does that make sense to you?
>
> Two questions.
>
>  - If a user follows the push.default advice, does it have any
>    advantage to set branch.autosetupmerge=simple at all?

Probably not?

It really depends what they set push.default to:
* If they set it to upstream/tracking, then
branch.autosetupmerge=simple doesn't make much sense. You can set
both, but the outcome is effectively the same as setting push.default
to simple - not very useful.
* If they set it to "current", then it probably doesn't make sense
because what they're angling for is probably a triangular workflow,
which branch.autosetupmerge=simple very explicitly doesn't support /
doesn't make sense for. "matching" seems to be an extreme version of
the same setup.
* If they set it to "nothing" I'm not sure - I haven't understood in
what workflows that makes sense.

Generally, I expect that branch.autosetupmerge=simple makes the most
sense with push.default left at the default of "simple", for...
"simple" workflows :)

>
>  - If a user follows the branch.autosetupmerge=simple advice, what
>    happens their "git push" on a branch that the .merge is not set
>    due to this configuration?  Shouldn't they have to set up the
>    push.default for these branches anyway?

If the user follows the branch.autosetupmerge=simple advice (and
leaves push.default at the "simple" default), what they get at push
time will depend on whether they branched from a same-name remote
branch or anything else:

If they branched from a same-name remote branch, their "git push" will
be perfectly uneventful / unsurprising: they will simply push to the
remote branch. This is the same as without
branch.autosetupmerge=simple.

If they branched from a different-name remote branch (they created an
new / independent local branch), then no remote tracking relationship
will have been set up, and instead of the "fatal: The upstream branch
of your current branch does not match
the name of your current branch" error and advice, they will get a
much simpler error and advice:

---
fatal: The current branch whatevs has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin whatevs
---

When they follow those instructions, they will be in the "simple"
setup same as if they had just branched from same-name.

Importantly, as soon as they enable branch.autosetupmerge=simple, they
never see the original mismatching-name error and advice anymore -
they never again end up with mismatching names at all. (except in edge
cases like branch renames)

>
> While it might be a good thing to mention branch.autosetupmerge
> configuration variable, I am not sure if "To instead avoid" is a
> good thing to say here.  It sounds as if the user can ignore
> push.default as long as branch.autosetupmerge is taken care of, but
> I suspect that is not the case.

I disagree. If they get that error and advice, then their push.default
is set to "simple". If they then set their branch.autosetupmerge to
"simple" also, this is the simple coherent setup that I, at least,
would recommend to non-experts.

> Setting the latter to 'simple'
> means there are *MORE* branches that do not have .remote/.merge set
> up, doesn't it?  Which in turn means that we are relying more on
> what push.default is set to, right?

No - the idea here is that instead of telling push.default to do
something *independent* of the tracking branch (like, for example,
"current"), the setup the user ends up with is one where the tracking
branch, if there is one, is always the same-name where you will push
to.

When you create a new branch (by branching with a new name), your new
branch doesn't initially have an upstream tracking branch - and that's
right and correct, there's literally nothing on the server for you to
track yet - but the first time you push, the (existing) advice
encourages you to set up that tracking relationship. In this flow you
very explicitly *don't* rely on push.default, because you never want
to end up in a confusing (un-simple) situation where what you're
pulling from and what you're pushing to aren't the same thing - a
triangular workflow.

The "push the current branch and set the remote as upstream" advice is
consistent with how many/most GUIs will handle first push for a branch
that does not have an upstream tracking relationship yet - GUIs will
typically automatically specify (or set the UI default to) the
"--set-upstream" option on that first push.

  reply	other threads:[~2022-04-20 21:32 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24  9:45 [PATCH 0/3] adding new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-24  9:45 ` [PATCH 1/3] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-02-24 19:20   ` Junio C Hamano
2022-02-24  9:45 ` [PATCH 2/3] t3200: tests for new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-24  9:45 ` [PATCH 3/3] branch documentation: new autosetupmerge " Tao Klerks via GitGitGadget
2022-02-24 19:38   ` Junio C Hamano
2022-02-25 18:52 ` [PATCH v2 0/2] adding new branch.autosetupmerge " Tao Klerks via GitGitGadget
2022-02-25 18:52   ` [PATCH v2 1/2] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-02-25 20:15     ` Junio C Hamano
2022-02-27 23:59       ` Tao Klerks
2022-02-25 18:52   ` [PATCH v2 2/2] t3200: tests for new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-28  7:14   ` [PATCH v3 0/2] adding " Tao Klerks via GitGitGadget
2022-02-28  7:14     ` [PATCH v3 1/2] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-02-28 10:39       ` Ævar Arnfjörð Bjarmason
2022-03-02  9:35         ` Tao Klerks
2022-03-20 17:00           ` Tao Klerks
2022-02-28  7:14     ` [PATCH v3 2/2] t3200: tests for new branch.autosetupmerge option "simple" Tao Klerks via GitGitGadget
2022-02-28  9:34       ` Ævar Arnfjörð Bjarmason
2022-03-01  2:58         ` Eric Sunshine
2022-03-01  9:59           ` Tao Klerks
2022-03-01  9:59         ` Tao Klerks
2022-03-21  6:17     ` [PATCH v4] merge: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-04-18 18:15       ` Josh Steadmon
2022-04-20  5:12         ` Tao Klerks
2022-04-20 17:19           ` Josh Steadmon
2022-04-20 17:43           ` Junio C Hamano
2022-04-20 21:31             ` Tao Klerks [this message]
2022-04-21  1:53               ` Junio C Hamano
2022-04-21 10:04                 ` Tao Klerks
2022-04-22  2:27                   ` Junio C Hamano
2022-04-22  9:24                     ` Tao Klerks
2022-04-22 13:27                       ` Tao Klerks
2022-04-23  4:44                       ` Junio C Hamano
2022-04-24 11:57                         ` Tao Klerks
2022-04-29  7:31                           ` Tao Klerks
2022-04-29  9:56       ` [PATCH v5 0/3] New options to support "simple" centralized workflow Tao Klerks via GitGitGadget
2022-04-29  9:56         ` [PATCH v5 1/3] branch: new autosetupmerge option 'simple' for matching branches Tao Klerks via GitGitGadget
2022-04-29  9:56         ` [PATCH v5 2/3] push: default to single remote even when not named origin Tao Klerks via GitGitGadget
2022-04-29  9:56         ` [PATCH v5 3/3] push: new config option "push.autoSetupRemote" supports "simple" push Tao Klerks via GitGitGadget
2022-04-29 18:50         ` [PATCH v5 0/3] New options to support "simple" centralized workflow Junio C Hamano
2022-04-30 15:48           ` Tao Klerks

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='CAPMMpohQei9vBBm=7hC=N5LPwzMCED=fZcXyePnrkLCHfCJTZw@mail.gmail.com' \
    --to=tao@klerks.biz \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=steadmon@google.com \
    --cc=sunshine@sunshineco.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).