From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 3034C1F953 for ; Fri, 10 Dec 2021 09:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239245AbhLJJ2Z (ORCPT ); Fri, 10 Dec 2021 04:28:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239221AbhLJJ2Z (ORCPT ); Fri, 10 Dec 2021 04:28:25 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72343C061746 for ; Fri, 10 Dec 2021 01:24:50 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id z5so28417284edd.3 for ; Fri, 10 Dec 2021 01:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:references:user-agent:in-reply-to :message-id:mime-version; bh=rDzz0BpDLVXiEWJdZc/ZnL9fubDVPfTgdzGhIjacxq0=; b=D80X/krSU8Vd04CzLWf5A0Kl79FQofsPMdWNIQJNyv+4iB+JnFnH2FPdNDf9Qy/tyE t6KflUQinavkx3ousBihW7IBKitY1x2FXMVKJRCA91yPn+C0wyR0u2f/M2buTTGhp25B WRmK7ruzFnQSw1O0t3cbqWf4M9jQjC0soWf8z8KsBA0su0B8BR0eJHuBjkjsi1Ow76LI ME7794i3LQJofF4hPrrPeYMe1euMLI4pAhhHpR07pHYitEyx/rC2+rORo+v/Ek/Q9jo7 Z+pOybL5fMWLiqt3n74LM30qW1KnvQEBI2PnkT4iS/S2hT2NQ4CEoqJF8rIIELOeo6dD ifpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:references:user-agent :in-reply-to:message-id:mime-version; bh=rDzz0BpDLVXiEWJdZc/ZnL9fubDVPfTgdzGhIjacxq0=; b=2GWouA2voExwVi5ryyxPbzdo6LnAyK6DVdLd6wW2j90jJQy3XbilGrGdndGTh3cGs0 qlqx0WMqSS2jtsJAkvhaTIdJIYDTYGLeB8gCQiMzCQDX8vq58v4TvDFktzVrTh4Gmj94 Z9wh0qcFA01UTS7BueM1N8NY/oEiLS11XB0a+vHPXFC6QfcA5a5E8bF7tAitylzMQqjZ 371HBqr5+E/A0CVATiyhxv1wGYd4/CbXFVXbLd76te7KylR5wZg+ZM+ITcRwcaF7XJhs yJt/fztUiSG6K7P2RYSNJ00UD/U7hNOmrar6pheATyrm6DZdTeDpI9gH2Z5/GppmklTd ynWQ== X-Gm-Message-State: AOAM532pA6R4XgfpmyvMlzoIGAwqHTucEtq2nXOgR/sr8rJAs0vzvfIN fzjFrdGstVIEf077XtGj6U4OqeRJ2s9TtA== X-Google-Smtp-Source: ABdhPJy//zkhIzUlsB2JGCU43vkH5ozL6RDpv9Yra8SkNPr1GXiSgs1hrBrYyt2MnjCMh/OoLj38lQ== X-Received: by 2002:a17:907:3daa:: with SMTP id he42mr23007436ejc.160.1639128288726; Fri, 10 Dec 2021 01:24:48 -0800 (PST) Received: from gmgdl (j120189.upc-j.chello.nl. [24.132.120.189]) by smtp.gmail.com with ESMTPSA id yd13sm1140482ejb.39.2021.12.10.01.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 01:24:47 -0800 (PST) Received: from avar by gmgdl with local (Exim 4.95) (envelope-from ) id 1mvc91-000Ev6-A3; Fri, 10 Dec 2021 10:24:47 +0100 From: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason To: ZheNing Hu via GitGitGadget Cc: git@vger.kernel.org, Junio C Hamano , Christian Couder , Hariom Verma , "brian m. carlson" , =?utf-8?B?Tmd1eeG7hW4g?= =?utf-8?B?VGjDoWkgTmfhu41j?= Duy , Eric Sunshine , ZheNing Hu Subject: Re: [PATCH 2/2] checkout: introduce "--to-branch" option Date: Fri, 10 Dec 2021 09:59:43 +0100 References: <254b352e31029d8151eb6a974fdf8c127340cf79.1639117329.git.gitgitgadget@gmail.com> User-agent: Debian GNU/Linux bookworm/sid; Emacs 27.1; mu4e 1.6.10 In-reply-to: <254b352e31029d8151eb6a974fdf8c127340cf79.1639117329.git.gitgitgadget@gmail.com> Message-ID: <211210.86y24sdd7k.gmgdl@evledraar.gmail.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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=