From: ZheNing Hu <adlternative@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>,
"Git List" <git@vger.kernel.org>,
"Christian Couder" <christian.couder@gmail.com>,
"Hariom Verma" <hariom18599@gmail.com>,
"brian m. carlson" <sandals@crustytoothpaste.net>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>
Subject: Re: [PATCH 2/2] checkout: introduce "--to-branch" option
Date: Sat, 11 Dec 2021 15:51:01 +0800 [thread overview]
Message-ID: <CAOLTT8Rx9M9=a5M8UeDrJqMayTXo=dvdanVDLi7QLdPX8W_Tzw@mail.gmail.com> (raw)
In-Reply-To: <xmqq5yrwm7km.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年12月11日周六 06:14写道:
>
> "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > When we want checkout to a branch (e.g. dev1) which reference
> > to a commit, but sometimes we only remember the tag (e.g. v1.1)
> > on it, we will use `git checkout v1.1` to find the commit first,
> > git will be in the state of deatching HEAD, so we have to search the
> > branches on the commit and checkout the branch we perfer. This will
> > be a bit cumbersome.
> >
> > Introduce "--to-branch" option, `git checkout --to-branch <tag>`
> > and `git checkout --to-branch <commit>` will search all branches
> > and find a unique branch reference to the commit (or the commit which
> > the tag reference to) and checkout to it. If the commit have more
> > than one branches, it will report error "here are more than one
> > branch on commit".
>
> Sorry, but the above explanation does not make any sense to me.
>
> It is unclear if you mean "dev1" exactly point at the commit tagged
> as v1.1, or you want the branch "dev1" that is a descedanant of
> v1.1. Without telling that to the reader, the above explanation is
> useless.
>
I meant the former.
> And whether you meant the former or the latter, neither use case does
> not make much sense.
>
> First, suppose you meant "checkout --to-branch v1.1" to find a
> branch whose tip exactly points at v1.1. You instead check out
> "dev1" branch, and work on it to advance its history. When you are
> done, you may go to another branch and work on something else.
>
> But then what? When you need another topic that also needs to be
> later merge-able to v1.1, "checkout --to-branch v1.1" no longer will
> be able to find "dev1", because, well, you have already used it to
> build something else.
>
> So, "--to-branch v1.1" that finds and checks out a branch whose tip
> exactly points at v1.1 would be pretty useless.
>
Well, I didn't consider what you said before. I just want to find a shortcut
for "oid -> branches" and "tag -> branches". And I can quickly use it to
switch branches.
> So let's correct the unwritten assumption and say "--to-branch v1.1"
> finds a branch that is descendant of the tag. It is like I have
> maint-2.33 branch to prepare for v2.33.1, v2.33.2,... maintenance
> releases and being able to find maint-2.33 by saying v2.33.2 (or
> v2.33.1) _might_ be convenient.
>
> But that would only be true if there is only one single branch per
> family of tags (in the above example, v2.33.* tags). You cannot use
> the workflow where many topic branches run in parallel, and get
> merged to the integration branch(es) only after they are ready,
> because you need bugfix-1-for-v2.33, bugfix-2-for-v2.33,... branches
> all forked from v2.33.0 (or a commit with a later tag in the v2.33.*
> family) to cook these independent fixes that are destined for the
> maint-2.33 integration branch, so you cannot uniquely find maint-2.33
> by saying v2.33.0 or v2.33.1 or whatever.
>
Well, in the case of many branches pointing to one commit, this "--to-branch"
is not very useful.
> I also sense that the first paragraph of the proposed log message
> for this commit hints that the user needs a bit more studying of
> existing tools. When we know v1.1 but do not know if we already
> have branches that are based on it, we DO NOT do "git checkout v1.1".
> Instead the first thing we would do is "git branch --contains v1.1"
> (add "--no-merged main" to exclude the branches that have already
> graduated to 'main').
>
"git branch --contains v1.1" can find all branches whose history contains the
commit tagged as v1.1. So what if "git checkout --contains v1.1"?
If there is only one branch, checkout to it; if there are multiple branches,
it will degenerate into "git branch --contains v1.1" to show these branches to
the user. Of course this feature is not very consistent with my
original intention...
> So, for this partcular topic, what I would recommend is *not* jump
> in and add a new feature, but to study what's available and build a
> workflow around the existing features.
>
>
Thanks.
--
ZheNing Hu
next prev parent reply other threads:[~2021-12-11 7:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 6:22 [PATCH 0/2] checkout: introduce "--to-branch" option ZheNing Hu via GitGitGadget
2021-12-10 6:22 ` [PATCH 1/2] checkout: handling branch_info memory leak ZheNing Hu via GitGitGadget
2021-12-10 7:13 ` Ævar Arnfjörð Bjarmason
2021-12-10 6:22 ` [PATCH 2/2] checkout: introduce "--to-branch" option ZheNing Hu via GitGitGadget
2021-12-10 8:34 ` Christian Couder
2021-12-11 6:34 ` ZheNing Hu
2021-12-10 8:59 ` Ævar Arnfjörð Bjarmason
2021-12-11 7:11 ` ZheNing Hu
2021-12-10 11:51 ` Bagas Sanjaya
2021-12-11 7:12 ` ZheNing Hu
2021-12-10 22:14 ` Junio C Hamano
2021-12-11 7:51 ` ZheNing Hu [this message]
2021-12-12 18:46 ` Junio C Hamano
2021-12-13 19:55 ` Ævar Arnfjörð Bjarmason
2021-12-13 21:36 ` Junio C Hamano
2021-12-13 21:52 ` Junio C Hamano
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='CAOLTT8Rx9M9=a5M8UeDrJqMayTXo=dvdanVDLi7QLdPX8W_Tzw@mail.gmail.com' \
--to=adlternative@gmail.com \
--cc=avarab@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=hariom18599@gmail.com \
--cc=pclouds@gmail.com \
--cc=sandals@crustytoothpaste.net \
--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.
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).