From: Ævar Arnfjörð Bjarmason Date: Fri, 10 Dec 2021 08:59:43 GMT Subject: Re: [PATCH 2/2] checkout: introduce "--to-branch" option Message-ID: <211210.86y24sdd7k.gmgdl@evledraar.gmail.com> In-Reply-To: <254b352e31029d8151eb6a974fdf8c127340cf79.1639117329.git.gitgitgadget@gmail.com> On Fri, Dec 10 2021, ZheNing Hu via GitGitGadget wrote: > From: ZheNing Hu > > 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 ` > and `git checkout --to-branch ` 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". > > Signed-off-by: ZheNing Hu > --- > Documentation/git-checkout.txt | 8 +++- > builtin/checkout.c | 33 +++++++++++++ > t/t2018-checkout-branch.sh | 85 ++++++++++++++++++++++++++++++++++ > t/t9902-completion.sh | 1 + > 4 files changed, 126 insertions(+), 1 deletion(-) > > diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt > index d473c9bf387..2a240699fd9 100644 > --- a/Documentation/git-checkout.txt > +++ b/Documentation/git-checkout.txt > @@ -10,7 +10,7 @@ SYNOPSIS > [verse] > 'git checkout' [-q] [-f] [-m] [] > 'git checkout' [-q] [-f] [-m] --detach [] > -'git checkout' [-q] [-f] [-m] [--detach] > +'git checkout' [-q] [-f] [-m] [--detach] [-w|--to-branch] > 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] [] > 'git checkout' [-f|--ours|--theirs|-m|--conflict=