From: Xavier Morel <xmo@odoo.com>
To: tao@klerks.biz
Cc: git@vger.kernel.org
Subject: Re: branch.autoSetupMerge option for "if name matches only"?
Date: Wed, 9 Feb 2022 14:46:37 +0100 [thread overview]
Message-ID: <b54a6cde-5065-632b-012c-0d6f777249ef@odoo.com> (raw)
In-Reply-To: <CAPMMpog6vKBfYEWqKDgK7YQQ96pPVMH7hYPXUHMnJsgLNgYMXA@mail.gmail.com>
I found this message when trying to see if someone had already suggested
something along those lines.
In fact I would be even more restrictive: what I wanted to propose was
to only automatically setup the merge on implicit remote tracking
branches, that is:
git switch foo
if there is no such branch locally will look for the corresponding
branch in the remotes, and will create a matching local one. In that
case it makes a lot of sense to create a remote-tracking branch: when
implicitly checking out a remote branch, it's likely the goal is to
track it.
The issue is that
git switch -c bar foo
will do the same, despite explicitely creating a differently named
branch, which is probably some sort of feature which needs to be
remote-ed somewhere else. If this issue is not caught immediately it is
possible to push directly upstream by mistake.
Upon reading the documentation of `git switch` I actually believed this
would behave correctly given `autoSetupMerge=false`:
--guess, --no-guess
If <branch> is not found but there does exist a tracking branch
in exactly one remote (call it <remote>) with
a matching name, treat as equivalent to
$ git switch -c <branch> --track <remote>/<branch>
Because `--guess` is the default for the `git switch <name>` form, this
description made me believe the tracking would be forced.
Sadly it is not so, setting `autoSetupMerge=false` will also disable
automatic remote-tracking on guessed branch.
As far as I'm concerned, `git switch` actually behaving as documented
would resolve the entire issue (especially if it were possible to
disable `git checkout` somehow, such that I would have to force muscle
memory).
This is made more annoying because
git switch -t foo
*does not work*, frustratingly (if as documented, this time) `-t`
implies `-c`. So it's not even possible to remember to type `git switch
-t remotebranch` and then live happily with `autoSetupMerge=false`. This
makes `autoSetupMerge=false` a lot more frustrating that necessary.
next prev parent reply other threads:[~2022-02-09 13:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 18:58 branch.autoSetupMerge option for "if name matches only"? Tao Klerks
2022-02-09 13:46 ` Xavier Morel [this message]
2022-02-24 16:47 ` 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
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=b54a6cde-5065-632b-012c-0d6f777249ef@odoo.com \
--to=xmo@odoo.com \
--cc=git@vger.kernel.org \
--cc=tao@klerks.biz \
/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).