From patchwork Wed Jan 30 09:48:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 110D813BF for ; Wed, 30 Jan 2019 09:48:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1E882E47B for ; Wed, 30 Jan 2019 09:48:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E597F2E47E; Wed, 30 Jan 2019 09:48:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BE2F2E47B for ; Wed, 30 Jan 2019 09:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728672AbfA3Jsn (ORCPT ); Wed, 30 Jan 2019 04:48:43 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46191 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3Jsn (ORCPT ); Wed, 30 Jan 2019 04:48:43 -0500 Received: by mail-pl1-f195.google.com with SMTP id t13so10802766ply.13 for ; Wed, 30 Jan 2019 01:48:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MBk5a69TGV6LtsCwXdBSZ6V23iSvTPo6GaA6IpkcwYk=; b=kvZ4BP5Dd+ZgEPbsaeMc0jWaavvAK0+e5C+WHjSp0aMBzcdOvj71qBmbqYENy+3Azo IRjbQzTfYcFMEypIs2qjfQ/EtNlz3zS65MZ7WFHshmAvih9wOdX1LYWjKSG0CBqE+0Jh /f78zbJIg7vP2lhRCKrnCjbwJRQtQs+4NUJGbA8yZCHBOhqfBtZrKTbyfiyzJ1FcoZye YtqDVs+nQ6+TSyxREZyCgKwPxZFIwcLzpVgXZKEPjV37MRZUq9VUXUzMT5k6AzKVjve7 m3ip4DbEJyV39Tugtn91fqGOoQWexizBK1lTFdXQGmCj6S5Ei7+bZDLRMW1OtOhL2d9Z jWMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MBk5a69TGV6LtsCwXdBSZ6V23iSvTPo6GaA6IpkcwYk=; b=na0Cik9v2uXLJYMoOZy+sdRTavXCIG+vsjcQKYQiH8vzea7cYnLD8bmk7thAEp0hn/ LGbC3r3MKEE0utng8mT7H2jfKdbp+5xPShk6H7laNnZ0BKQUZAL0IsLt8vH+DsMFAqxk S+bXHggAkzsAsBZQJBaVAQhBivNu52QpusDbB59ZQC3CjFEJMJlwEEAPwwkSFqolvGui 0xx0FQzgh7Nxrmp+EiSbLTkl+iFgDRaIGHP7IEhdkfAp7yOtmgR/EpTDQueQVFRSQrOR /Z1jcFu0jwPZCr3RUt0x4qFGHrBdjyNueEjnx21IQKiBk8pb1E/Pvwa8hZ3OVGDBHNs6 wEzQ== X-Gm-Message-State: AJcUukeljd8guGtCMEaDwU3aroQA2walYO+Mh24Ef85aKu9vJjYIoFbJ 79kejnS5Yo9O2crXSrxDTjhxa0QQ X-Google-Smtp-Source: ALg8bN6zYcmjQ6MTQkSJ8Bqf2tFm9m8QQDcnzz2z3mgfXSbGt249pU8oEp2MKnMdyQbZ6iX7dbZV3Q== X-Received: by 2002:a17:902:1005:: with SMTP id b5mr29793190pla.310.1548841722577; Wed, 30 Jan 2019 01:48:42 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 22sm5754262pgd.85.2019.01.30.01.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:48:41 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:48:37 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 01/19] git-checkout.txt: fix one syntax line Date: Wed, 30 Jan 2019 16:48:13 +0700 Message-Id: <20190130094831.10420-2-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP can be omitted in this syntax, and it's actually documented a few paragraphs down: You could omit , in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, if exists, for the current branch. Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/git-checkout.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index ce7d38b8b7..bc7fbdb8d2 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -23,7 +23,7 @@ or the specified tree. If no paths are given, 'git checkout' will also update `HEAD` to set the specified branch as the current branch. -'git checkout' :: +'git checkout' []:: To prepare for working on , switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the From patchwork Wed Jan 30 09:48:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1685413B5 for ; Wed, 30 Jan 2019 09:48:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE1051FFDB for ; Wed, 30 Jan 2019 09:48:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF6052018F; Wed, 30 Jan 2019 09:48:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB761FFDB for ; Wed, 30 Jan 2019 09:48:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729148AbfA3Jss (ORCPT ); Wed, 30 Jan 2019 04:48:48 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41146 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3Jss (ORCPT ); Wed, 30 Jan 2019 04:48:48 -0500 Received: by mail-pl1-f196.google.com with SMTP id u6so10820976plm.8 for ; Wed, 30 Jan 2019 01:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qAzFqgUwqjAHLnU7Ja5dEQliPy6wwQ9QDXW/m4Sboe8=; b=nwv0NFoSks/g6PJbjm2ed81wciPN/QNbRIbBknyZY9Am7EMIhHGK3O7EFfa1xJeHCk 9MoyWA9U2WgtU6obTX4qWl0A7zKFy9eplPnpRtttYX38s4knb9XJpC7sZB0tZ++nsJ50 UGL1vu/oVZphVJvebRh9NwfTdB1ziXg9NGPcx1CcdHHBGGfOBl3bhDe9dx4FtwreBqBn JTE75UFF4NgY0e1xDcdYkF9PHDYbSw4oRwMp4P5Zx0r7B4dX2Iy0uxVFYYyJ3gkJe4vj mICkMS09PqxPzAa5bLWjdQKvONAVJ4sCwvuc2TrHeQcPLX/2pLR/4ykTP63s0J7SysZp DgnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qAzFqgUwqjAHLnU7Ja5dEQliPy6wwQ9QDXW/m4Sboe8=; b=gZT9cr9KfipUDpMDK/+jn1BgMn+NiQnSQ5rNfpWhXKxHZ3UrR16LWWDm15FrmEfLrp rrxmiOWx1c0bt6a22PLwoFZb/uqqNX01aO0ecSkS17XMcKtu1F0AeAhOkL2IEKvWgYit q3SCFoSBDmupSWxPBmpnL0YkOd597eUY2ixlOpc0Zo9vRDBWjd8Dmp/Znkcd/tzNY2An FY1o3ivSpP9cdHIdN5iCtge+38fQy8YSKba7RfwNk8otDteH3ujsX0UTjIF5BGusRHqc vPvg24XgvbPWHSt/eC9WLUcYTje766k9PxDLuVzuJ4yUw9jwZlOlOaOgkVkeQ5jpA6mg fQoA== X-Gm-Message-State: AJcUukdR1y5XAoCdlwJIyS7VIaWFcLuM2RXjQj3aVEVrRTvQGfBQdO4f vUJFPDGZLHjwZojP71YjohGuplY2 X-Google-Smtp-Source: ALg8bN5xY/ihRrGOUkmjZFnvu1U4xZUnxKTTnYp6Y/6a8W5UO+Qutu9ghnXKpNM/Wx2VW8YimmTeqg== X-Received: by 2002:a17:902:fa2:: with SMTP id 31mr29866285plz.75.1548841727290; Wed, 30 Jan 2019 01:48:47 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 19sm6026253pfs.108.2019.01.30.01.48.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:48:46 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:48:42 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 02/19] doc: document --overwrite-ignore Date: Wed, 30 Jan 2019 16:48:14 +0700 Message-Id: <20190130094831.10420-3-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I added this option in git-checkout and git-merge in c1d7036b6b (checkout,merge: disallow overwriting ignored files with --no-overwrite-ignore - 2011-11-27) but did not remember to update documentation. This completes that commit. Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/git-checkout.txt | 5 +++++ Documentation/git-merge.txt | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index bc7fbdb8d2..9ac01f7967 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -270,6 +270,11 @@ Note that this option uses the no overlay mode by default (see also out anyway. In other words, the ref can be held by more than one worktree. +--[no-]overwrite-ignore:: + Silently overwrite ignored files when switching branches. This + is the default behavior. Use --no-overwrite-ignore to abort + the operation when the new branch contains ignored files. + --[no-]recurse-submodules:: Using --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject. If diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 4cc86469f3..0480e9d0f0 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -87,6 +87,10 @@ will be appended to the specified message. Allow the rerere mechanism to update the index with the result of auto-conflict resolution if possible. +--[no-]overwrite-ignore:: + Silently overwrite ignored files from the merge result. This + is the default behavior. Use --no-overwrite-ignore to abort. + --abort:: Abort the current conflict resolution process, and try to reconstruct the pre-merge state. From patchwork Wed Jan 30 09:48:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90CF813B5 for ; Wed, 30 Jan 2019 09:48:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E0272D732 for ; Wed, 30 Jan 2019 09:48:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F16E2D78C; Wed, 30 Jan 2019 09:48:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 062A12D732 for ; Wed, 30 Jan 2019 09:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729280AbfA3Jsx (ORCPT ); Wed, 30 Jan 2019 04:48:53 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41149 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3Jsw (ORCPT ); Wed, 30 Jan 2019 04:48:52 -0500 Received: by mail-pl1-f193.google.com with SMTP id u6so10821083plm.8 for ; Wed, 30 Jan 2019 01:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/OKrVEIdtHGuBbjw0txuo5PJ5Bolb0l97rR/T1Ood7I=; b=noLqwbHXQCMdQfBrLemZg2JJXVxbVmh7eVy97UcwU4dWW7obeppbyyLvXWrx1ThM8Z dydJSOwk4+V7OHh7opINc8Cw2eqVhvIAVGvGaBE74+Ku6SUIqX3aRHjq1Ht2dpGaqglC OC3yFQpxnNT7GsjYMxSyFUP50pFb1vzZAGt1G5sweN4nBTtTPTfYPCKJ6IGfcQafIhH1 LkKzsm7MGPfxqG/jYGgaXj5Seb+jvFEF98P/DYqHOH8Cp0/14RhN6EQ7gDzJbVKvGkT1 Rjvkh9fJ5aFA/I+uJT8TyfZdFGijtifwrQNQY72euMBEdOZXheijtB21fmd6aK36R1WK 4BfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/OKrVEIdtHGuBbjw0txuo5PJ5Bolb0l97rR/T1Ood7I=; b=REOL4vw6Chp4sDiYRy5L84xb8HP/qFcp7HjF7b7s7j7y4WWqXjgNW749Ta713GBTF+ xSjO0cVt2BEC+TyNFg6x+6l1fiM/fvvXfGxtjqXx5eqHxj1FgG/ixF1G6X08FDkQS63d MXoxvxSxZc5Jz5vHMrPvqzN5FEMfTkV1FS/9NOlCLi8V+nsX3gEdQ+XB6XD6bzeAqxcs tmz5bTg6bj7dP49jFwns2maPEtGdjGAFVq4yiIy4PmhKkez8ohiGijHUiVnat1GjPCWe I9kl7JlEN4Fac9aGlADAOyz2LgWvMwwqmPryuDJ6cDs2l17IT1DNP689eDqbMN4xvidk jXeA== X-Gm-Message-State: AJcUukdjfKxprV470Gy4USfkThKohndv8jCQthl+gX1CjrXHx3wRwjBl cJu5yWL2tslGh+/dWEbaRxDkc74Q X-Google-Smtp-Source: ALg8bN5KJmxQGaQE/qpkDVP+YpcXgWUPmWZQ1hy99wD24qNc84ZucOO3Go7uT4t6Nnnqn+LiMESaag== X-Received: by 2002:a17:902:d70b:: with SMTP id w11mr30171490ply.294.1548841732102; Wed, 30 Jan 2019 01:48:52 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id 22sm5758411pgd.85.2019.01.30.01.48.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:48:51 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:48:47 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 03/19] t: rename t2014-switch.sh to t2014-checkout-switch.sh Date: Wed, 30 Jan 2019 16:48:15 +0700 Message-Id: <20190130094831.10420-4-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The old name does not really say that this is about 'checkout -b'. See 49d833dc07 (Revert "checkout branch: prime cache-tree fully" - 2009-05-12) for more information Signed-off-by: Nguyễn Thái Ngọc Duy --- t/{t2014-switch.sh => t2014-checkout-switch.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename t/{t2014-switch.sh => t2014-checkout-switch.sh} (100%) diff --git a/t/t2014-switch.sh b/t/t2014-checkout-switch.sh similarity index 100% rename from t/t2014-switch.sh rename to t/t2014-checkout-switch.sh From patchwork Wed Jan 30 09:48:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B2C813BF for ; Wed, 30 Jan 2019 09:48:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543382D732 for ; Wed, 30 Jan 2019 09:48:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 469492D78C; Wed, 30 Jan 2019 09:48:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEC382D732 for ; Wed, 30 Jan 2019 09:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730137AbfA3Js5 (ORCPT ); Wed, 30 Jan 2019 04:48:57 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45901 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3Js5 (ORCPT ); Wed, 30 Jan 2019 04:48:57 -0500 Received: by mail-pl1-f196.google.com with SMTP id a14so10799703plm.12 for ; Wed, 30 Jan 2019 01:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sQk9AT2smGrSAzGg2LXGB/pZY5NLA2Xrmm1iKFp6AOE=; b=X37XSIW2Nay+ysrXfsWmntS/n7JpGjSVbJxFqn9UDFh8oeFB6p8MYGU3cYVlfjYPVi AFvyh29loG6qpPTMHTEGya/fvHx9KcP603Fla9wwjL0j8L/c1AtKnjOI8NGrxE4fJ+jy dDub95JNpicBcNNrMxPdc0xCG73XWVk1E9X+j5kz4GqhpcPDSHlaqjP+MY7PW7O3WUuv Asr1ykMAxgTZ0RFBf0z6Z1BjYm2HHBjPmM+FsI7hQe3GdCiRQXg75uFIPRXEnQzSzuMX MtHLZudoGsZBtPhnoqmlEx5wvPeh7HoPod37nKhgfQPWazhafsHNV59m6f7+fCoV0zGW e4JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sQk9AT2smGrSAzGg2LXGB/pZY5NLA2Xrmm1iKFp6AOE=; b=ZfN61bAzLAsgan2Ut9RMm11bRQPosdTNj8Hlx7l8ZqctaBogqKKcDY5IUTvyDn+qcW uIXT5z4b01nMqc9d2VokA27NYINayX4bfPbNRuW1Uk0KNlimAwGty3YrHjSAfaVfJ55K wdQoESAGn+dCZOg+WDkdTAasHO9HuaZ/Pu4+2vgJNb/h2k5vRY4mqXnheLHJ/kaIPUd4 Jw3kJfQ0v4pQT0wU1N4e08D9cqqxEOcJ4j3vNECTbdspaN2x0V/l1YkDOIH4AHa+sjIi 4hXQy16eRXOVO3wGqEAOdU+sYhd4q9fWmVtTBff7ekNbwaXB1qxaP/aTcaEPHpi0DKGJ 3jRw== X-Gm-Message-State: AJcUuke7a8q1Cs3hG1D8SSpm6oJ9opdt/yzQQTxnBpLZl+vK49EPmYLP 6y4m4Rwa8zzZEJ78Ev0Sgqsl0Bci X-Google-Smtp-Source: ALg8bN6jqRHbgo34cEqTpH9Do7imfeIEprCfELJt+8TSKuamVDqZ7Zp8BGiShbVc/98nU3obzzXnqg== X-Received: by 2002:a17:902:f24:: with SMTP id 33mr29979548ply.65.1548841736794; Wed, 30 Jan 2019 01:48:56 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id s15sm1458144pgv.59.2019.01.30.01.48.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:48:56 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:48:52 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 04/19] checkout: factor out some code in parse_branchname_arg() Date: Wed, 30 Jan 2019 16:48:16 +0700 Message-Id: <20190130094831.10420-5-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is in preparation for the new command restore, which also needs to parse opts->source_tree but does not need all the disambiguation logic. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/checkout.c | 51 ++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index f63d864a91..12b7e08d4e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1068,6 +1068,34 @@ static int git_checkout_config(const char *var, const char *value, void *cb) return git_xmerge_config(var, value, NULL); } +static void setup_new_branch_info_and_source_tree( + struct branch_info *new_branch_info, + struct checkout_opts *opts, + struct object_id *rev, + const char *arg) +{ + struct tree **source_tree = &opts->source_tree; + struct object_id branch_rev; + + new_branch_info->name = arg; + setup_branch_path(new_branch_info); + + if (!check_refname_format(new_branch_info->path, 0) && + !read_ref(new_branch_info->path, &branch_rev)) + oidcpy(rev, &branch_rev); + else + new_branch_info->path = NULL; /* not an existing branch */ + + new_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1); + if (!new_branch_info->commit) { + /* not a commit */ + *source_tree = parse_tree_indirect(rev); + } else { + parse_commit_or_die(new_branch_info->commit); + *source_tree = get_commit_tree(new_branch_info->commit); + } +} + static int parse_branchname_arg(int argc, const char **argv, int dwim_new_local_branch_ok, struct branch_info *new_branch_info, @@ -1075,10 +1103,8 @@ static int parse_branchname_arg(int argc, const char **argv, struct object_id *rev, int *dwim_remotes_matched) { - struct tree **source_tree = &opts->source_tree; const char **new_branch = &opts->new_branch; int argcount = 0; - struct object_id branch_rev; const char *arg; int dash_dash_pos; int has_dash_dash = 0; @@ -1200,26 +1226,11 @@ static int parse_branchname_arg(int argc, const char **argv, argv++; argc--; - new_branch_info->name = arg; - setup_branch_path(new_branch_info); - - if (!check_refname_format(new_branch_info->path, 0) && - !read_ref(new_branch_info->path, &branch_rev)) - oidcpy(rev, &branch_rev); - else - new_branch_info->path = NULL; /* not an existing branch */ + setup_new_branch_info_and_source_tree(new_branch_info, opts, rev, arg); - new_branch_info->commit = lookup_commit_reference_gently(the_repository, rev, 1); - if (!new_branch_info->commit) { - /* not a commit */ - *source_tree = parse_tree_indirect(rev); - } else { - parse_commit_or_die(new_branch_info->commit); - *source_tree = get_commit_tree(new_branch_info->commit); - } - - if (!*source_tree) /* case (1): want a tree */ + if (!opts->source_tree) /* case (1): want a tree */ die(_("reference is not a tree: %s"), arg); + if (!has_dash_dash) { /* case (3).(d) -> (1) */ /* * Do not complain the most common case From patchwork Wed Jan 30 09:48:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4399213BF for ; Wed, 30 Jan 2019 09:49:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28CB72D776 for ; Wed, 30 Jan 2019 09:49:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BBEA2D7A9; Wed, 30 Jan 2019 09:49:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 508E52D776 for ; Wed, 30 Jan 2019 09:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730254AbfA3JtD (ORCPT ); Wed, 30 Jan 2019 04:49:03 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33624 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3JtD (ORCPT ); Wed, 30 Jan 2019 04:49:03 -0500 Received: by mail-pf1-f194.google.com with SMTP id c123so11202361pfb.0 for ; Wed, 30 Jan 2019 01:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QCPTp1r5EZFNiGyQZ2bCrEBN/03rDLfjxcnzvraacas=; b=tv09vVCOCZNHKO1ocYOP0/gJAopVDs4nUm6LuiOjaqSVG8K5oqChlXoiAcoS8prjpO Ak8XSBlF440ZUD8t0Yb5FZBs0SU3qg3u7BPHRr6OMNybnCZpXWCxfBmSSTU3tO5/WafF fd8gqmhh0nUmKBc0KAuXI2otabd4u4/vPnMGSKCpIDPTG3mLU0wb40r5gNrDN71yzyYp Pq8MMpQhsK1jhbppSeaypGFKhKR5pEZFsofIaLg8+dPyUg+AjFFvNONtN9DvgkzzOlgo VrPU/avZsrdTn+H7XtyVSyQ4Td8DD7+GA+JTNU+RvBOayWJ8k4QZTkdJT7qPk9qyAzeM vXXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QCPTp1r5EZFNiGyQZ2bCrEBN/03rDLfjxcnzvraacas=; b=jxKbe6gzJEf868wBgo0xkM12meL6UR96seMJmJt0Kg4jQgNNinQuftmemog4GSiso0 cGn2P+qfJHqTfQVWwG0/fPdHh/b0Pv1nl491EG9S0wLpImN9WAxGChvQNEah6Oq3QRL4 yIvNGyWlKVCiKmxwS0aLznbSICpqg/XRZGB1gzGzT5Gaa+g3/mJBaTFOogLG7jzgo8L3 t0GuiMPvPSQymn8Mjbp3TW0C76gqiUTWHQsoZFk3n6WdfVzaa1gdyB/xbtObl3PzEFGb doczglldUQr9esWVOthwI1ZV4FhAlKibffKZsgDgWnQlPoOGYxh3BacRO+ezpfBboEcT U4Vg== X-Gm-Message-State: AJcUukc+BvYF1qVCL2O1Zjq1Pb4wiqPE1pUnT/61fe4YEtduro0Ip4BS 0P63qDF7F7tEzmelkkA3lfkPjBbc X-Google-Smtp-Source: ALg8bN5umQeDLZ3Ni05KiPpZRx4VHiwG/WiGQOuter7Kpx9rVeEfkvgVWsjMZQB/tJhRmNkk9VpD+A== X-Received: by 2002:a62:9913:: with SMTP id d19mr29856073pfe.107.1548841741635; Wed, 30 Jan 2019 01:49:01 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id w184sm1346919pgd.34.2019.01.30.01.48.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:49:00 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:48:57 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 05/19] checkout: make "opts" in cmd_checkout() a pointer Date: Wed, 30 Jan 2019 16:48:17 +0700 Message-Id: <20190130094831.10420-6-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "opts" will soon be moved out of cmd_checkout(). To keep changes in that patch smaller, convert "opts" to a pointer and keep the real thing behind "real_opts". Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/checkout.c | 115 +++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 12b7e08d4e..66f99e788d 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1326,82 +1326,83 @@ static int checkout_branch(struct checkout_opts *opts, int cmd_checkout(int argc, const char **argv, const char *prefix) { - struct checkout_opts opts; + struct checkout_opts real_opts; + struct checkout_opts *opts = &real_opts; struct branch_info new_branch_info; char *conflict_style = NULL; int dwim_new_local_branch, no_dwim_new_local_branch = 0; int dwim_remotes_matched = 0; struct option options[] = { - OPT__QUIET(&opts.quiet, N_("suppress progress reporting")), - OPT_STRING('b', NULL, &opts.new_branch, N_("branch"), + OPT__QUIET(&opts->quiet, N_("suppress progress reporting")), + OPT_STRING('b', NULL, &opts->new_branch, N_("branch"), N_("create and checkout a new branch")), - OPT_STRING('B', NULL, &opts.new_branch_force, N_("branch"), + OPT_STRING('B', NULL, &opts->new_branch_force, N_("branch"), N_("create/reset and checkout a branch")), - OPT_BOOL('l', NULL, &opts.new_branch_log, N_("create reflog for new branch")), - OPT_BOOL(0, "detach", &opts.force_detach, N_("detach HEAD at named commit")), - OPT_SET_INT('t', "track", &opts.track, N_("set upstream info for new branch"), + OPT_BOOL('l', NULL, &opts->new_branch_log, N_("create reflog for new branch")), + OPT_BOOL(0, "detach", &opts->force_detach, N_("detach HEAD at named commit")), + OPT_SET_INT('t', "track", &opts->track, N_("set upstream info for new branch"), BRANCH_TRACK_EXPLICIT), - OPT_STRING(0, "orphan", &opts.new_orphan_branch, N_("new-branch"), N_("new unparented branch")), - OPT_SET_INT_F('2', "ours", &opts.writeout_stage, + OPT_STRING(0, "orphan", &opts->new_orphan_branch, N_("new-branch"), N_("new unparented branch")), + OPT_SET_INT_F('2', "ours", &opts->writeout_stage, N_("checkout our version for unmerged files"), 2, PARSE_OPT_NONEG), - OPT_SET_INT_F('3', "theirs", &opts.writeout_stage, + OPT_SET_INT_F('3', "theirs", &opts->writeout_stage, N_("checkout their version for unmerged files"), 3, PARSE_OPT_NONEG), - OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)"), + OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"), PARSE_OPT_NOCOMPLETE), - OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")), - OPT_BOOL_F(0, "overwrite-ignore", &opts.overwrite_ignore, + OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")), + OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore, N_("update ignored files (default)"), PARSE_OPT_NOCOMPLETE), OPT_STRING(0, "conflict", &conflict_style, N_("style"), N_("conflict style (merge or diff3)")), - OPT_BOOL('p', "patch", &opts.patch_mode, N_("select hunks interactively")), - OPT_BOOL(0, "ignore-skip-worktree-bits", &opts.ignore_skipworktree, + OPT_BOOL('p', "patch", &opts->patch_mode, N_("select hunks interactively")), + OPT_BOOL(0, "ignore-skip-worktree-bits", &opts->ignore_skipworktree, N_("do not limit pathspecs to sparse entries only")), OPT_BOOL(0, "no-guess", &no_dwim_new_local_branch, N_("do not second guess 'git checkout '")), - OPT_BOOL(0, "ignore-other-worktrees", &opts.ignore_other_worktrees, + OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees, N_("do not check if another worktree is holding the given ref")), { OPTION_CALLBACK, 0, "recurse-submodules", NULL, "checkout", "control recursive updating of submodules", PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater }, - OPT_BOOL(0, "progress", &opts.show_progress, N_("force progress reporting")), - OPT_BOOL(0, "overlay", &opts.overlay_mode, N_("use overlay mode (default)")), + OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")), + OPT_BOOL(0, "overlay", &opts->overlay_mode, N_("use overlay mode (default)")), OPT_END(), }; - memset(&opts, 0, sizeof(opts)); + memset(opts, 0, sizeof(*opts)); memset(&new_branch_info, 0, sizeof(new_branch_info)); - opts.overwrite_ignore = 1; - opts.prefix = prefix; - opts.show_progress = -1; - opts.overlay_mode = -1; + opts->overwrite_ignore = 1; + opts->prefix = prefix; + opts->show_progress = -1; + opts->overlay_mode = -1; - git_config(git_checkout_config, &opts); + git_config(git_checkout_config, opts); - opts.track = BRANCH_TRACK_UNSPECIFIED; + opts->track = BRANCH_TRACK_UNSPECIFIED; argc = parse_options(argc, argv, prefix, options, checkout_usage, PARSE_OPT_KEEP_DASHDASH); dwim_new_local_branch = !no_dwim_new_local_branch; - if (opts.show_progress < 0) { - if (opts.quiet) - opts.show_progress = 0; + if (opts->show_progress < 0) { + if (opts->quiet) + opts->show_progress = 0; else - opts.show_progress = isatty(2); + opts->show_progress = isatty(2); } if (conflict_style) { - opts.merge = 1; /* implied */ + opts->merge = 1; /* implied */ git_xmerge_config("merge.conflictstyle", conflict_style, NULL); } - if ((!!opts.new_branch + !!opts.new_branch_force + !!opts.new_orphan_branch) > 1) + if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1) die(_("-b, -B and --orphan are mutually exclusive")); - if (opts.overlay_mode == 1 && opts.patch_mode) + if (opts->overlay_mode == 1 && opts->patch_mode) die(_("-p and --overlay are mutually exclusive")); /* @@ -1409,14 +1410,14 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) * and new_branch_force and new_orphan_branch will tell us which one of * -b/-B/--orphan is being used. */ - if (opts.new_branch_force) - opts.new_branch = opts.new_branch_force; + if (opts->new_branch_force) + opts->new_branch = opts->new_branch_force; - if (opts.new_orphan_branch) - opts.new_branch = opts.new_orphan_branch; + if (opts->new_orphan_branch) + opts->new_branch = opts->new_orphan_branch; /* --track without -b/-B/--orphan should DWIM */ - if (opts.track != BRANCH_TRACK_UNSPECIFIED && !opts.new_branch) { + if (opts->track != BRANCH_TRACK_UNSPECIFIED && !opts->new_branch) { const char *argv0 = argv[0]; if (!argc || !strcmp(argv0, "--")) die(_("--track needs a branch name")); @@ -1425,7 +1426,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) argv0 = strchr(argv0, '/'); if (!argv0 || !argv0[1]) die(_("missing branch name; try -b")); - opts.new_branch = argv0 + 1; + opts->new_branch = argv0 + 1; } /* @@ -1444,56 +1445,56 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) if (argc) { struct object_id rev; int dwim_ok = - !opts.patch_mode && + !opts->patch_mode && dwim_new_local_branch && - opts.track == BRANCH_TRACK_UNSPECIFIED && - !opts.new_branch; + opts->track == BRANCH_TRACK_UNSPECIFIED && + !opts->new_branch; int n = parse_branchname_arg(argc, argv, dwim_ok, - &new_branch_info, &opts, &rev, + &new_branch_info, opts, &rev, &dwim_remotes_matched); argv += n; argc -= n; } if (argc) { - parse_pathspec(&opts.pathspec, 0, - opts.patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0, + parse_pathspec(&opts->pathspec, 0, + opts->patch_mode ? PATHSPEC_PREFIX_ORIGIN : 0, prefix, argv); - if (!opts.pathspec.nr) + if (!opts->pathspec.nr) die(_("invalid path specification")); /* * Try to give more helpful suggestion. * new_branch && argc > 1 will be caught later. */ - if (opts.new_branch && argc == 1) + if (opts->new_branch && argc == 1) die(_("'%s' is not a commit and a branch '%s' cannot be created from it"), - argv[0], opts.new_branch); + argv[0], opts->new_branch); - if (opts.force_detach) + if (opts->force_detach) die(_("git checkout: --detach does not take a path argument '%s'"), argv[0]); - if (1 < !!opts.writeout_stage + !!opts.force + !!opts.merge) + if (1 < !!opts->writeout_stage + !!opts->force + !!opts->merge) die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\n" "checking out of the index.")); } - if (opts.new_branch) { + if (opts->new_branch) { struct strbuf buf = STRBUF_INIT; - if (opts.new_branch_force) - opts.branch_exists = validate_branchname(opts.new_branch, &buf); + if (opts->new_branch_force) + opts->branch_exists = validate_branchname(opts->new_branch, &buf); else - opts.branch_exists = - validate_new_branchname(opts.new_branch, &buf, 0); + opts->branch_exists = + validate_new_branchname(opts->new_branch, &buf, 0); strbuf_release(&buf); } UNLEAK(opts); - if (opts.patch_mode || opts.pathspec.nr) { - int ret = checkout_paths(&opts, new_branch_info.name); + if (opts->patch_mode || opts->pathspec.nr) { + int ret = checkout_paths(opts, new_branch_info.name); if (ret && dwim_remotes_matched > 1 && advice_checkout_ambiguous_remote_branch_name) advise(_("'%s' matched more than one remote tracking branch.\n" @@ -1512,6 +1513,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) dwim_remotes_matched); return ret; } else { - return checkout_branch(&opts, &new_branch_info); + return checkout_branch(opts, &new_branch_info); } } From patchwork Wed Jan 30 09:48:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C32E513BF for ; Wed, 30 Jan 2019 09:49:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF8AA2D732 for ; Wed, 30 Jan 2019 09:49:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A42002D78C; Wed, 30 Jan 2019 09:49:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35B462D732 for ; Wed, 30 Jan 2019 09:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730319AbfA3JtI (ORCPT ); Wed, 30 Jan 2019 04:49:08 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:39820 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbfA3JtH (ORCPT ); Wed, 30 Jan 2019 04:49:07 -0500 Received: by mail-pg1-f194.google.com with SMTP id r11so39955pgp.6 for ; Wed, 30 Jan 2019 01:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+9/Kpl+61rd31y0vY+VgLy2XCFr4qeOVICy0P2P9Q64=; b=tyBxJ/G041i+w1ykRWIKhoVZwpEkCBwiOlpyjTDkuE05MoGnA8hEqk7/mQKxT1XvWT qxHqqN03FC4vzr3yG1++DBe217AlD5l8mFo7zNVEwLtNLHRuYinb+65iAV8lwRnDhSGI pSzSNkbF+sXoOJgUbyEm7S0SCNZ+LL6Q3LmCK7hFz7Z+mVVnG02TygHBxrqRKbt+FbUg pkyP2oCRLGqJMMHvT53ZUB1wPPNKBilfd52dubo5SzfnTbVgN7sy5fF/xcAJLx7NEkis VQ4ywmYZ1f2nwQvSBozTzlwFsZprwOdOBQCF4WNNxNc2mKWW0KYTqTu/3kOybTyXMb8W bvvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+9/Kpl+61rd31y0vY+VgLy2XCFr4qeOVICy0P2P9Q64=; b=qakhuvrcfTZ1NS11pN64IXnTnex4Y1pL7be/sFY+TLWT6Swb//mkKAZN0d1uuYHXO8 lJwgqYSrXVjsuRNU+HQBpyYsoit4x6NbdKxrKU1puVz012YC5SN1NxLw36N7nzReNbhU 2M1xVVmt64W9irG20uv9eWjloaFiVik99vGjuYOruUjblWvEriR+K23lqtx1jw0XD2EB O1qEdSTkMJ9BJq2KMFt6JjEXlBB6zuef7A9+V7Xxf2Pfq/z5TIUo4C8c2Wzagw5oOqeS nlX3glrHoIu5hjbj6mCjgXnowsHWRb2gNXBughVu+zWABqyGpxiwhiiInKn53jDiFwpI hDmA== X-Gm-Message-State: AJcUukdnqZ5yoeTGadQiyRy+VqrSoK4CCmAFHeypAUhipQmt6uaMvodq ENrpQHl5s7GOJP6naNkmY83A8Yr1 X-Google-Smtp-Source: ALg8bN6NwAWE0mI5a+WdIX1aj5X2Hz+os3gsuDzBJDoDotWDCtluTDusgHKYDPm8VXICoH75evCqXw== X-Received: by 2002:a62:1484:: with SMTP id 126mr29461337pfu.257.1548841746620; Wed, 30 Jan 2019 01:49:06 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id m9sm5774705pgd.32.2019.01.30.01.49.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:49:05 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:49:01 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 06/19] checkout: move 'confict_style' and 'dwim_..' to checkout_opts Date: Wed, 30 Jan 2019 16:48:18 +0700 Message-Id: <20190130094831.10420-7-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These local variables are referenced by struct option[]. This struct will soon be broken down, moved away and we can't rely on local variables anymore. Move these two to struct checkout_opts in preparation for that. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/checkout.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 66f99e788d..5914dd3619 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -46,6 +46,8 @@ struct checkout_opts { int show_progress; int count_checkout_paths; int overlay_mode; + int no_dwim_new_local_branch; + /* * If new checkout options are added, skip_merge_working_tree * should be updated accordingly. @@ -57,6 +59,7 @@ struct checkout_opts { int new_branch_log; enum branch_track track; struct diff_options diff_options; + char *conflict_style; int branch_exists; const char *prefix; @@ -1329,8 +1332,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) struct checkout_opts real_opts; struct checkout_opts *opts = &real_opts; struct branch_info new_branch_info; - char *conflict_style = NULL; - int dwim_new_local_branch, no_dwim_new_local_branch = 0; + int dwim_new_local_branch; int dwim_remotes_matched = 0; struct option options[] = { OPT__QUIET(&opts->quiet, N_("suppress progress reporting")), @@ -1355,12 +1357,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore, N_("update ignored files (default)"), PARSE_OPT_NOCOMPLETE), - OPT_STRING(0, "conflict", &conflict_style, N_("style"), + OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"), N_("conflict style (merge or diff3)")), OPT_BOOL('p', "patch", &opts->patch_mode, N_("select hunks interactively")), OPT_BOOL(0, "ignore-skip-worktree-bits", &opts->ignore_skipworktree, N_("do not limit pathspecs to sparse entries only")), - OPT_BOOL(0, "no-guess", &no_dwim_new_local_branch, + OPT_BOOL(0, "no-guess", &opts->no_dwim_new_local_branch, N_("do not second guess 'git checkout '")), OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees, N_("do not check if another worktree is holding the given ref")), @@ -1378,6 +1380,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts->prefix = prefix; opts->show_progress = -1; opts->overlay_mode = -1; + opts->no_dwim_new_local_branch = 0; git_config(git_checkout_config, opts); @@ -1386,7 +1389,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, checkout_usage, PARSE_OPT_KEEP_DASHDASH); - dwim_new_local_branch = !no_dwim_new_local_branch; + dwim_new_local_branch = !opts->no_dwim_new_local_branch; if (opts->show_progress < 0) { if (opts->quiet) opts->show_progress = 0; @@ -1394,9 +1397,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts->show_progress = isatty(2); } - if (conflict_style) { + if (opts->conflict_style) { opts->merge = 1; /* implied */ - git_xmerge_config("merge.conflictstyle", conflict_style, NULL); + git_xmerge_config("merge.conflictstyle", opts->conflict_style, NULL); } if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1) From patchwork Wed Jan 30 09:48:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26F4313BF for ; Wed, 30 Jan 2019 09:49:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12D402D732 for ; Wed, 30 Jan 2019 09:49:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0753B2D78C; Wed, 30 Jan 2019 09:49:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ECEF2D732 for ; Wed, 30 Jan 2019 09:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730479AbfA3JtM (ORCPT ); Wed, 30 Jan 2019 04:49:12 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44240 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730329AbfA3JtM (ORCPT ); Wed, 30 Jan 2019 04:49:12 -0500 Received: by mail-pl1-f193.google.com with SMTP id e11so10804995plt.11 for ; Wed, 30 Jan 2019 01:49:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pQH3hqjxsDKVTc/CSA4hRuj+mYNkHhNGyPng4PDcIio=; b=pH63gX663E1TynEmAlrp8ZrxqnoPneHzHMXtDAB2YnvpFmnLWwr7aslsFgjHIIyQ67 aaf4NINVvFqyrKCQNTdj8TFncIWErSixvlxhl9GuoLJ1LI3uNad8X7bH0d2SAqYZV3KH 3kW0RZiD46gcSYowCf3r+xUVvQqrgd1fLhJ6Xia6qdsa/wG9ho3mMxDgi6D/hP1+DtfB mJlORb+7vTrpIRsJ9ZSrK1GwJ2/r8Qv6IqseIsrWC2uGN8nRYeLD6LO0LjBgYmATN6Jd 1RMw1QYHXtS76nadZNnSHw8iiJneJxOlHbbYQPjFYT1MciaL+tJn0anAuwoLmljKMdhO 4Ekg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pQH3hqjxsDKVTc/CSA4hRuj+mYNkHhNGyPng4PDcIio=; b=i6x+3p4QlhmdJKQv/elLSL8na6J6HoV5R3s3NWZBNcorheCLOjLIKjvKerYZPtHwb/ Xnuss3kRqp1T9YthGzEhRP0f7LhufwWafSEiqUS1KzTfVFgL1uAfIv42dppqVVNccwZO JPeWfwTYKw0L5QnU8tKtvWLgFG92r/9HnmC4jw6k26pFvobsHkYms41HGIwvo0kTL//x BM6I6b9evCzIlcba8y433t4UskG9h9rTrp4jg+pigtODUKbYLICFdzS18Y5zz5bMQ3Ck yGUCxCp3XLtlCouJwnmMwvSW37UsZZwXZQd6ZMHlCuVHG2lfADKNxXiMGra1/88gJcHe pQRg== X-Gm-Message-State: AJcUukfASjfR3AvAiB0zxnMvHQQ2eUSSiOpAjyyUnC5oRAHZy5pO8Gwd Vn2U/HWbSrxXwq049sWctDEUhjhm X-Google-Smtp-Source: ALg8bN5gFCvgEYtNXeDSrIMNbl1e06vV0E2HTxpJLEwyGZyU+LooMzo2ugnPR8Titk2yZqdWK9D1hw== X-Received: by 2002:a17:902:850c:: with SMTP id bj12mr29137359plb.46.1548841751229; Wed, 30 Jan 2019 01:49:11 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id v12sm1526665pgg.41.2019.01.30.01.49.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:49:10 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:49:06 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 07/19] checkout: split options[] array in three pieces Date: Wed, 30 Jan 2019 16:48:19 +0700 Message-Id: <20190130094831.10420-8-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a preparation step for introducing new commands that do parts of what checkout does. There will be two new commands, one is about switching branches, detaching HEAD... one about checking out paths. These share the a subset of command line options. The rest of command line options are separate. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/checkout.c | 82 +++++++++++++++++++++++++++++++++------------- parse-options-cb.c | 17 ++++++++++ parse-options.h | 3 +- 3 files changed, 78 insertions(+), 24 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 5914dd3619..8ea1349cce 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1327,15 +1327,31 @@ static int checkout_branch(struct checkout_opts *opts, return switch_branches(opts, new_branch_info); } -int cmd_checkout(int argc, const char **argv, const char *prefix) +static struct option *add_common_options(struct checkout_opts *opts, + struct option *prevopts) { - struct checkout_opts real_opts; - struct checkout_opts *opts = &real_opts; - struct branch_info new_branch_info; - int dwim_new_local_branch; - int dwim_remotes_matched = 0; struct option options[] = { OPT__QUIET(&opts->quiet, N_("suppress progress reporting")), + { OPTION_CALLBACK, 0, "recurse-submodules", NULL, + "checkout", "control recursive updating of submodules", + PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater }, + OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")), + OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"), + PARSE_OPT_NOCOMPLETE), + OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")), + OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"), + N_("conflict style (merge or diff3)")), + OPT_END() + }; + struct option *newopts = parse_options_concat(prevopts, options); + free(prevopts); + return newopts; +} + +static struct option *add_switch_branch_options(struct checkout_opts *opts, + struct option *prevopts) +{ + struct option options[] = { OPT_STRING('b', NULL, &opts->new_branch, N_("branch"), N_("create and checkout a new branch")), OPT_STRING('B', NULL, &opts->new_branch_force, N_("branch"), @@ -1345,34 +1361,49 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) OPT_SET_INT('t', "track", &opts->track, N_("set upstream info for new branch"), BRANCH_TRACK_EXPLICIT), OPT_STRING(0, "orphan", &opts->new_orphan_branch, N_("new-branch"), N_("new unparented branch")), + OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore, + N_("update ignored files (default)"), + PARSE_OPT_NOCOMPLETE), + OPT_BOOL(0, "no-guess", &opts->no_dwim_new_local_branch, + N_("second guess 'git checkout '")), + OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees, + N_("do not check if another worktree is holding the given ref")), + OPT_END() + }; + struct option *newopts = parse_options_concat(prevopts, options); + free(prevopts); + return newopts; +} + +static struct option *add_checkout_path_options(struct checkout_opts *opts, + struct option *prevopts) +{ + struct option options[] = { OPT_SET_INT_F('2', "ours", &opts->writeout_stage, N_("checkout our version for unmerged files"), 2, PARSE_OPT_NONEG), OPT_SET_INT_F('3', "theirs", &opts->writeout_stage, N_("checkout their version for unmerged files"), 3, PARSE_OPT_NONEG), - OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"), - PARSE_OPT_NOCOMPLETE), - OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")), - OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore, - N_("update ignored files (default)"), - PARSE_OPT_NOCOMPLETE), - OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"), - N_("conflict style (merge or diff3)")), OPT_BOOL('p', "patch", &opts->patch_mode, N_("select hunks interactively")), OPT_BOOL(0, "ignore-skip-worktree-bits", &opts->ignore_skipworktree, N_("do not limit pathspecs to sparse entries only")), - OPT_BOOL(0, "no-guess", &opts->no_dwim_new_local_branch, - N_("do not second guess 'git checkout '")), - OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees, - N_("do not check if another worktree is holding the given ref")), - { OPTION_CALLBACK, 0, "recurse-submodules", NULL, - "checkout", "control recursive updating of submodules", - PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater }, - OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")), OPT_BOOL(0, "overlay", &opts->overlay_mode, N_("use overlay mode (default)")), - OPT_END(), + OPT_END() }; + struct option *newopts = parse_options_concat(prevopts, options); + free(prevopts); + return newopts; +} + +int cmd_checkout(int argc, const char **argv, const char *prefix) +{ + struct checkout_opts real_opts; + struct checkout_opts *opts = &real_opts; + struct branch_info new_branch_info; + int dwim_remotes_matched = 0; + int dwim_new_local_branch; + struct option *options = NULL; memset(opts, 0, sizeof(*opts)); memset(&new_branch_info, 0, sizeof(new_branch_info)); @@ -1386,6 +1417,11 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts->track = BRANCH_TRACK_UNSPECIFIED; + options = parse_options_dup(options); + options = add_common_options(opts, options); + options = add_switch_branch_options(opts, options); + options = add_checkout_path_options(opts, options); + argc = parse_options(argc, argv, prefix, options, checkout_usage, PARSE_OPT_KEEP_DASHDASH); diff --git a/parse-options-cb.c b/parse-options-cb.c index e2f3eaed07..76eb5c211b 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -122,6 +122,23 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) return 0; } +struct option *parse_options_dup(const struct option *o) +{ + struct option *opts; + int nr = 0; + + while (o && o->type != OPTION_END) { + nr++; + o++; + } + + ALLOC_ARRAY(opts, nr + 1); + memcpy(opts, o - nr, sizeof(*o) * nr); + memset(opts + nr, 0, sizeof(*opts)); + opts[nr].type = OPTION_END; + return opts; +} + struct option *parse_options_concat(struct option *a, struct option *b) { struct option *ret; diff --git a/parse-options.h b/parse-options.h index 14fe32428e..6846a5b1e0 100644 --- a/parse-options.h +++ b/parse-options.h @@ -237,7 +237,8 @@ extern int parse_options_step(struct parse_opt_ctx_t *ctx, extern int parse_options_end(struct parse_opt_ctx_t *ctx); -extern struct option *parse_options_concat(struct option *a, struct option *b); +struct option *parse_options_dup(const struct option *a); +struct option *parse_options_concat(struct option *a, struct option *b); /*----- some often used options -----*/ extern int parse_opt_abbrev_cb(const struct option *, const char *, int); From patchwork Wed Jan 30 09:48:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10788083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0D2D13BF for ; Wed, 30 Jan 2019 09:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA32A2DF2D for ; Wed, 30 Jan 2019 09:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE28E2DFA8; Wed, 30 Jan 2019 09:49:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E3BC2DF2D for ; Wed, 30 Jan 2019 09:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730505AbfA3JtS (ORCPT ); Wed, 30 Jan 2019 04:49:18 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39842 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730399AbfA3JtR (ORCPT ); Wed, 30 Jan 2019 04:49:17 -0500 Received: by mail-pf1-f195.google.com with SMTP id r136so11177689pfc.6 for ; Wed, 30 Jan 2019 01:49:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D4BWYFWctsZf/a9vQ/u6CZdbREnDd4iGqq76tkFTkwc=; b=efdRmyvB7wG6hOr3V93KYMAkv/jlqKc9eK82mpTIIo2cUl/8eVGeyIF+WleWN33K6S vY0BJIWsmhanA4/oXtF4PRLfBbEhij2WxZSEE5tKvLwNRi/Us5NtjCaqfEIe/9WfoppG zZfqHdbSW/mut69FvdH/kNzzHaclHPd3KhzEXbsR0nNW5dkK/htWYAjrW+u2kqXaTkWi e7LSUcswDmS/0OJ33NKJQeQe0jGFXbtNrjE6ODp+u6rfGeyZwxhMbSqULqwLGIjbQDxx WfK5zuQ37qHHQ2lQY+JyWJzgWep6N2n0Gz02lduPrd6LsIycXqFcJB0v4X7Em4Vu4CZy Rz5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D4BWYFWctsZf/a9vQ/u6CZdbREnDd4iGqq76tkFTkwc=; b=q5AeCdPQacAn2SbDxxJhC0YCGDTfpKHxBtc/JFSEshAlnBlkLV/QLxLgHnf6YvPBtB ZvwdG21v9yjy/9um22lIeoO4grLNVPfxMGPvhPbmYTsiu5/WthN5czEcn/rhLfheW76r OTrKXgqB5fNvNdqE7bpKDnula+9U31eSDMK0rpt2kwfC3XW6Q5+3i8+0rmG4OrLJqjSk yCn8+Th+Wmn/Q+umY5IPOUAjx4NPakF0A2yBxrLswcHEmrzFPVx+dlS7C5p/ZpLXHpeq CqkZyaQ9C3WDz8U9Fm8VoM9Iotaldisf8aJ1QqDr9pNiTfqx4rtiCCtIcgifvDoKincf u3Bg== X-Gm-Message-State: AJcUukcrt/oorqLY5x+IAeLom7L96bSbRzNvgd2CWWwCb5heweGvV5Bk 7XRPFumtaSSJClnIkoN43sfCYovl X-Google-Smtp-Source: ALg8bN5MkWyrdoBaM/lPnq8xgiB3aOB1RiirR/r5OBrvWHl6SLPqof+A+MMl7OwwrA3QjUTHofIZ4g== X-Received: by 2002:a65:560e:: with SMTP id l14mr26932335pgs.168.1548841755867; Wed, 30 Jan 2019 01:49:15 -0800 (PST) Received: from ash ([115.72.21.220]) by smtp.gmail.com with ESMTPSA id e86sm1756133pfb.6.2019.01.30.01.49.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:49:15 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Wed, 30 Jan 2019 16:49:11 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 08/19] checkout: split part of it to new command switch Date: Wed, 30 Jan 2019 16:48:20 +0700 Message-Id: <20190130094831.10420-9-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.682.gd5861c6d90 In-Reply-To: <20190130094831.10420-1-pclouds@gmail.com> References: <20190130094831.10420-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "git checkout" doing too many things is a source of confusion for many users (and it even bites old timers sometimes). To remedy that, the command will be split into two new ones: switch and something-to-checkout-paths. The good old "git checkout" command is still here and will be until all (or most of users) are sick of it. See the new man page for the final design of switch. The actual implementation though is still pretty much the same as "git checkout" and not completely aligned with the man page. Following patches will adjust their behavior to match the man page. Signed-off-by: Nguyễn Thái Ngọc Duy --- .gitignore | 1 + Documentation/config/advice.txt | 13 +- Documentation/config/branch.txt | 4 +- Documentation/config/checkout.txt | 9 +- Documentation/config/diff.txt | 3 +- Documentation/git-checkout.txt | 4 + Documentation/git-switch.txt | 236 ++++++++++++++++++++++++++++++ Documentation/gitattributes.txt | 3 +- Documentation/githooks.txt | 8 +- Makefile | 1 + builtin.h | 1 + builtin/checkout.c | 60 ++++++-- command-list.txt | 1 + git.c | 1 + 14 files changed, 318 insertions(+), 27 deletions(-) create mode 100644 Documentation/git-switch.txt diff --git a/.gitignore b/.gitignore index 0d77ea5894..8e2b89047f 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,7 @@ /git-submodule /git-submodule--helper /git-svn +/git-switch /git-symbolic-ref /git-tag /git-unpack-file diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt index 88620429ea..239d479506 100644 --- a/Documentation/config/advice.txt +++ b/Documentation/config/advice.txt @@ -42,7 +42,8 @@ advice.*:: state in the output of linkgit:git-status[1], in the template shown when writing commit messages in linkgit:git-commit[1], and in the help message shown - by linkgit:git-checkout[1] when switching branch. + by linkgit:git-switch[1] or + linkgit:git-checkout[1] when switching branch. statusUoption:: Advise to consider using the `-u` option to linkgit:git-status[1] when the command takes more than 2 seconds to enumerate untracked @@ -62,12 +63,14 @@ advice.*:: your information is guessed from the system username and domain name. detachedHead:: - Advice shown when you used linkgit:git-checkout[1] to - move to the detach HEAD state, to instruct how to create - a local branch after the fact. + Advice shown when you used + linkgit:git-switch[1] or linkgit:git-checkout[1] + to move to the detach HEAD state, to instruct how to + create a local branch after the fact. checkoutAmbiguousRemoteBranchName:: Advice shown when the argument to - linkgit:git-checkout[1] ambiguously resolves to a + linkgit:git-checkout[1] and linkgit:git-switch[1] + ambiguously resolves to a remote tracking branch on more than one remote in situations where an unambiguous argument would have otherwise caused a remote-tracking branch to be diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index 019d60ede2..8050466159 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -1,5 +1,5 @@ branch.autoSetupMerge:: - Tells 'git branch' and 'git checkout' to set up new branches + Tells 'git branch', 'git switch' and 'git checkout' to set up new branches so that linkgit:git-pull[1] will appropriately merge from the starting point branch. Note that even if this option is not set, this behavior can be chosen per-branch using the `--track` @@ -11,7 +11,7 @@ branch.autoSetupMerge:: branch. This option defaults to true. branch.autoSetupRebase:: - When a new branch is created with 'git branch' or 'git checkout' + When a new branch is created with 'git branch', 'git switch' or 'git checkout' that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch..rebase"). When `never`, rebase is never automatically set to true. diff --git a/Documentation/config/checkout.txt b/Documentation/config/checkout.txt index 73380a8d86..fc211eca58 100644 --- a/Documentation/config/checkout.txt +++ b/Documentation/config/checkout.txt @@ -1,5 +1,6 @@ checkout.defaultRemote:: - When you run 'git checkout ' and only have one + When you run 'git checkout ' + or 'git switch ' and only have one remote, it may implicitly fall back on checking out and tracking e.g. 'origin/'. This stops working as soon as you have more than one remote with a '' @@ -8,8 +9,10 @@ checkout.defaultRemote:: disambiguation. The typical use-case is to set this to `origin`. + -Currently this is used by linkgit:git-checkout[1] when 'git checkout -' will checkout the '' branch on another remote, +Currently this is used by linkgit:git-switch[1] and +linkgit:git-checkout[1] when 'git checkout ' +or 'git switch ' +will checkout the '' branch on another remote, and by linkgit:git-worktree[1] when 'git worktree add' refers to a remote branch. This setting might be used for other checkout-like commands or functionality in the future. diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt index e48bb987d7..b3b304ee12 100644 --- a/Documentation/config/diff.txt +++ b/Documentation/config/diff.txt @@ -78,7 +78,8 @@ diff.external:: diff.ignoreSubmodules:: Sets the default value of --ignore-submodules. Note that this affects only 'git diff' Porcelain, and not lower level 'diff' - commands such as 'git diff-files'. 'git checkout' also honors + commands such as 'git diff-files'. 'git checkout' + and 'git switch' also honor this setting when reporting uncommitted changes. Setting it to 'all' disables the submodule summary normally shown by 'git commit' and 'git status' when `status.submoduleSummary` is set unless it is diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 9ac01f7967..31c6cbef19 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -556,6 +556,10 @@ $ edit frotz $ git add frotz ------------ +SEE ALSO +-------- +linkgit:git-switch[1] + GIT --- Part of the linkgit:git[1] suite diff --git a/Documentation/git-switch.txt b/Documentation/git-switch.txt new file mode 100644 index 0000000000..953c9747b2 --- /dev/null +++ b/Documentation/git-switch.txt @@ -0,0 +1,236 @@ +git-switch(1) +============= + +NAME +---- +git-switch - Switch branches + +SYNOPSIS +-------- +[verse] +'git switch' [] [--guess] +'git switch' [] --detach [>] +'git switch' [] [[-c|-C|--orphan] ] [] + +DESCRIPTION +----------- +Switch to a specified branch and update files in the working tree to +match it. Optionally a new branch could be created with either `-c` or +`-C`, or detach from any branch with `--detach`, along with switching. + +OPTIONS +------- +:: + Branch to switch to. + +:: + Name for the new branch. + +:: + The name of a commit at which to switch to before creating a + new branch or detach from. ++ +You can use the `"@{-N}"` syntax to refer to the N-th last +branch/commit switched to "git switch" or "git checkout" +operation. You may also specify `-` which is synonymous to `"@{-1}`. ++ +As a special case, you may use `"A...B"` as a shortcut for the merge +base of `A` and `B` if there is exactly one merge base. You can leave +out at most one of `A` and `B`, in which case it defaults to `HEAD`. + +-c :: +--create :: + Create a new branch named and start it at + ; see linkgit:git-branch[1] for details. + +-C :: +--force-create :: + Creates the branch and start it at ; + if it already exists, then reset it to . This is + equivalent to running "git branch" with "-f"; see + linkgit:git-branch[1] for details. + +-d:: +--detach:: + Switch to a commit for inspection and discardable + experiments. See the "DETACHED HEAD" section in + linkgit:git-checkout[1] for details. + +-g:: +--guess:: + If is not found but there does exist a tracking + branch in exactly one remote (call it ) with a + matching name, treat as equivalent to ++ +------------ +$ git switch -c --track / +------------ ++ +If the branch exists in multiple remotes and one of them is named by +the `checkout.defaultRemote` configuration variable, we'll use that +one for the purposes of disambiguation, even if the `` isn't +unique across all remotes. Set it to e.g. `checkout.defaultRemote=origin` +to always checkout remote branches from there if `` is +ambiguous but exists on the 'origin' remote. See also +`checkout.defaultRemote` in linkgit:git-config[1]. + +-q:: +--quiet:: + Quiet, suppress feedback messages. + +-f:: +--force:: + Proceed even if the index or the working tree differs from + HEAD. This is used to throw away local changes. + +--[no-]progress:: + Progress status is reported on the standard error stream + by default when it is attached to a terminal, unless `--quiet` + is specified. This flag enables progress reporting even if not + attached to a terminal, regardless of `--quiet`. + +-t:: +--track:: + When creating a new branch, set up "upstream" configuration. + `-c` is implied. See "--track" in linkgit:git-branch[1] for + details. ++ +If no `-c` option is given, the name of the new branch will be derived +from the remote-tracking branch, by looking at the local part of the +refspec configured for the corresponding remote, and then stripping +the initial part up to the "*". This would tell us to use "hack" as +the local branch when branching off of "origin/hack" (or +"remotes/origin/hack", or even "refs/remotes/origin/hack"). If the +given name has no slash, or the above guessing results in an empty +name, the guessing is aborted. You can explicitly give a name with +`-c` in such a case. + +--no-track:: + Do not set up "upstream" configuration, even if the + branch.autoSetupMerge configuration variable is true. + +-m:: +--merge:: + If you have local modifications to one or more files that are + different between the current branch and the branch to which + you are switching, the command refuses to switch branches in + order to preserve your modifications in context. However, + with this option, a three-way merge between the current + branch, your working tree contents, and the new branch is + done, and you will be on the new branch. ++ +When a merge conflict happens, the index entries for conflicting +paths are left unmerged, and you need to resolve the conflicts +and mark the resolved paths with `git add` (or `git rm` if the merge +should result in deletion of the path). + +--conflict=