From patchwork Sun Dec 9 20:04:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720283 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 E968418A7 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA8102A0F7 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CECB42A104; Sun, 9 Dec 2018 20:05:15 +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 4CBF72A0FC for ; Sun, 9 Dec 2018 20:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726246AbeLIUFA (ORCPT ); Sun, 9 Dec 2018 15:05:00 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:32972 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbeLIUFA (ORCPT ); Sun, 9 Dec 2018 15:05:00 -0500 Received: by mail-wm1-f66.google.com with SMTP id r24so5136617wmh.0 for ; Sun, 09 Dec 2018 12:04:59 -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=/Xcnx2Do8YNDeBCKWPepvSPQuWc69kAWOsiXjVWUFKo=; b=SqTZ2Mcv7tBgytNKb45Xoa2PfjVns2XakQIOQrSLCCkyFT/7GCKbEZdlp1+KHjvCad 5fB/W8EBcL85oMNFX53lRXc3B6ImFWr3isYKECK3hUW0MPbX4Pm6nrAGMstbjfVx5k28 aNNciwOhlxTITM3XAX4nQL9Pf5uAKgY8ySB/Wz/nYx4lB+JbsqOHbbaMLjtxdNUiqAHc PbFvcj1UA02RS2I2gzRlhv+g0l8c5TngmCoExyqxO8J+yZgujGExPFxNOaLTveT+k/Sh ryFXbNufO6u5ovSJN1vbsuy0ID68GzJHDcAij/WtMIgqbRBlJIBF+L+7UoNiaQupsk/o tuuA== 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=/Xcnx2Do8YNDeBCKWPepvSPQuWc69kAWOsiXjVWUFKo=; b=Lc4XKjYF4LZz+FinZtSINuExvDhRWHxEIQ2abm9lp3JjjdGQ0zJoPIRQ2bDoBi9OVK HEEJ32HLrx/inGUID4UZENlsGIuxurHn4rC5+7HgN0TnPhwxfXf5iIea5k29zPUWJt13 7MYsRdXKf2ttbmjvcifDWR+5dvSx6szQ2kbIT9GucxTq3OcKJ8AkjHy2D7nsmgpckSt7 EeITeSjHsMIKG4zZ4Ad21+4nKNpDkQgdQZ4cXCFxYGQG7UAy0fVxosnS/PognpNJ87CM ng5f+54uGlu4Y8ixJ+F+nMwi4wqLaM6r2MRmvrMxtrE4a1PcQkBr7HKDXEoJU5YDrVNd bESg== X-Gm-Message-State: AA+aEWYX+5+jCDbLaFztBM7kR/FY/P+Fns6p/QPelgj1M606mcyvB2g/ bQFBdHEsYmPV/nQ/TO5WhURJkva2 X-Google-Smtp-Source: AFSGD/UXVv1s9R57UeAeKUVdJmVRNneBjOhu5pTFjpJUbKgmc9LzgzGC4d4NxYDyR1npW71wf5iZpw== X-Received: by 2002:a1c:cbc7:: with SMTP id b190mr9054437wmg.13.1544385898232; Sun, 09 Dec 2018 12:04:58 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id l78sm13504757wma.0.2018.12.09.12.04.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:04:57 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 1/8] move worktree tests to t24* Date: Sun, 9 Dec 2018 20:04:42 +0000 Message-Id: <20181209200449.16342-2-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 'git worktree' command used to be just another mode in 'git checkout', namely 'git checkout --to'. When the tests for the latter were retrofitted for the former, the test name was adjusted, but the test number was kept, even though the test is testing a different command now. t/README states: "Second digit tells the particular command we are testing.", so 'git worktree' should have a separate number just for itself. Move the worktree tests to t24* to adhere to that guideline. We're going to make use of the free'd up numbers in a subsequent commit. Signed-off-by: Thomas Gummerer --- t/{t2025-worktree-add.sh => t2400-worktree-add.sh} | 0 t/{t2026-worktree-prune.sh => t2401-worktree-prune.sh} | 0 t/{t2027-worktree-list.sh => t2402-worktree-list.sh} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename t/{t2025-worktree-add.sh => t2400-worktree-add.sh} (100%) rename t/{t2026-worktree-prune.sh => t2401-worktree-prune.sh} (100%) rename t/{t2027-worktree-list.sh => t2402-worktree-list.sh} (100%) diff --git a/t/t2025-worktree-add.sh b/t/t2400-worktree-add.sh similarity index 100% rename from t/t2025-worktree-add.sh rename to t/t2400-worktree-add.sh diff --git a/t/t2026-worktree-prune.sh b/t/t2401-worktree-prune.sh similarity index 100% rename from t/t2026-worktree-prune.sh rename to t/t2401-worktree-prune.sh diff --git a/t/t2027-worktree-list.sh b/t/t2402-worktree-list.sh similarity index 100% rename from t/t2027-worktree-list.sh rename to t/t2402-worktree-list.sh From patchwork Sun Dec 9 20:04:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720285 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 6C2D4679F for ; Sun, 9 Dec 2018 20:05:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EE02A0F7 for ; Sun, 9 Dec 2018 20:05:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 551BA2A0FC; Sun, 9 Dec 2018 20:05:16 +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 6D3812A101 for ; Sun, 9 Dec 2018 20:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbeLIUFC (ORCPT ); Sun, 9 Dec 2018 15:05:02 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36172 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726194AbeLIUFC (ORCPT ); Sun, 9 Dec 2018 15:05:02 -0500 Received: by mail-wr1-f65.google.com with SMTP id u3so8465857wrs.3 for ; Sun, 09 Dec 2018 12:05:00 -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=D7SOASY12vKEgpfKuattfmL/mEr/8ZnM0iuwElbYewg=; b=qUkZbaFZ1YsBKWx1Yo3dbvOV9y7/OJipJyUhrqkZAkEyiJXOoVyJogaRGh4GEQtOLK RyBb7GqYVAWjIf5zEKWqbFgWabU+Kp4Qxi7WVnk4el4XI0N4PMEH/bZd8n2JQ9yy8FX2 PKz6L5Ymgc1+IBt0Qb4KMfOrUXBLeBoDFRQl81RV9PVw8vrl792StkL52u/w6X94dkZK MxF8C3f7LMTZJdxWd/FMSVnjbYLrx50huUs+oOPUhaT/fbb1ye8VuBBxVc3EhQfgIpPo ET8RseakpEPMb0OdX8lr5p6CtUgrIjU7T3Rs1/Z74fw8JTiJg5CDt9Cc97ErOxrF8suh BqmQ== 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=D7SOASY12vKEgpfKuattfmL/mEr/8ZnM0iuwElbYewg=; b=Gfp2UAiRFYfH4+wKAp5KdxnnzzCS84vBNXnq0Kf84hMzuJC7UXiccuJ0+QvnU5V0T5 kfLFylPK1itWZcDvVXqOJP0BUY58TM8aEDuEZHmeUj0JCJ9N38Gf16O6P0pqIcZDXhlM TSG/4cAsKm5Q+MrflWGEgxdCi+tsE+eb+rrNFlbkSlXgyaaxW5I4pqI68DihdZ30B3KJ gF/VEDyJToVI7LRK6Tba+R/82hreDXSZClhESaiLsmG8aC19TV+uS5T7LO+158g2VD55 mpMm35ujYP5tshW5OttX+O0StWjezwa9h/xbtS2xlag8H22WRK1P4reR2jZ5aW5Y9pPo xeCQ== X-Gm-Message-State: AA+aEWZQleKlusQDATAGWTEupN+XMcDlpEW56WzX6C1a3+P5LXCcy1gC Wz99MJ7VuHyMZiXWkmfNL0JHjILQ X-Google-Smtp-Source: AFSGD/WD+COqdIlh2203vQpv7XJgqwPOVxyvtlYJuoaU/agGIG27xWnQKABBg/WKBDKMSaOPpOdP/A== X-Received: by 2002:adf:9591:: with SMTP id p17mr8148219wrp.224.1544385899841; Sun, 09 Dec 2018 12:04:59 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id s3sm7897603wmj.23.2018.12.09.12.04.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:04:59 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 2/8] entry: factor out unlink_entry function Date: Sun, 9 Dec 2018 20:04:43 +0000 Message-Id: <20181209200449.16342-3-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 Factor out the 'unlink_entry()' function from unpack-trees.c to entry.c. It will be used in other places as well in subsequent steps. As it's no longer a static function, also move the documentation to the header file to make it more discoverable. Signed-off-by: Thomas Gummerer --- cache.h | 5 +++++ entry.c | 15 +++++++++++++++ unpack-trees.c | 19 ------------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/cache.h b/cache.h index ca36b44ee0..c1c953e810 100644 --- a/cache.h +++ b/cache.h @@ -1542,6 +1542,11 @@ struct checkout { extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); extern void enable_delayed_checkout(struct checkout *state); extern int finish_delayed_checkout(struct checkout *state); +/* + * Unlink the last component and schedule the leading directories for + * removal, such that empty directories get removed. + */ +extern void unlink_entry(const struct cache_entry *ce); struct cache_def { struct strbuf path; diff --git a/entry.c b/entry.c index 5d136c5d55..3ec148ceee 100644 --- a/entry.c +++ b/entry.c @@ -508,3 +508,18 @@ int checkout_entry(struct cache_entry *ce, create_directories(path.buf, path.len, state); return write_entry(ce, path.buf, state, 0); } + +void unlink_entry(const struct cache_entry *ce) +{ + const struct submodule *sub = submodule_from_ce(ce); + if (sub) { + /* state.force is set at the caller. */ + submodule_move_head(ce->name, "HEAD", NULL, + SUBMODULE_MOVE_HEAD_FORCE); + } + if (!check_leading_path(ce->name, ce_namelen(ce))) + return; + if (remove_or_warn(ce->ce_mode, ce->name)) + return; + schedule_dir_for_removal(ce->name, ce_namelen(ce)); +} diff --git a/unpack-trees.c b/unpack-trees.c index 7570df481b..e8d1a6ac50 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -300,25 +300,6 @@ static void load_gitmodules_file(struct index_state *index, } } -/* - * Unlink the last component and schedule the leading directories for - * removal, such that empty directories get removed. - */ -static void unlink_entry(const struct cache_entry *ce) -{ - const struct submodule *sub = submodule_from_ce(ce); - if (sub) { - /* state.force is set at the caller. */ - submodule_move_head(ce->name, "HEAD", NULL, - SUBMODULE_MOVE_HEAD_FORCE); - } - if (!check_leading_path(ce->name, ce_namelen(ce))) - return; - if (remove_or_warn(ce->ce_mode, ce->name)) - return; - schedule_dir_for_removal(ce->name, ce_namelen(ce)); -} - static struct progress *get_progress(struct unpack_trees_options *o) { unsigned cnt = 0, total = 0; From patchwork Sun Dec 9 20:04:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720275 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 100C418B8 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04E602A106 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED5562A112; Sun, 9 Dec 2018 20:05: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 9732F2A106 for ; Sun, 9 Dec 2018 20:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726258AbeLIUFD (ORCPT ); Sun, 9 Dec 2018 15:05:03 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41288 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbeLIUFD (ORCPT ); Sun, 9 Dec 2018 15:05:03 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so8431186wrs.8 for ; Sun, 09 Dec 2018 12:05: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=nJGaB58FVsS5jxtSvE0P91JPilGw8ccwEcTgQkXH45k=; b=r1xH9jvhvqs8z8NLSFB8qMYV8MHxTEVlutfN737CRePdDBu3AdZIxJnioT5iCgXXa+ bxt+d6wjOFe2hTFv9uRuKFGOcrFQLOEVWigKu17Q8SZaGUXfSCriShCvQ6ozJVwmQdK9 uvOc2nWSv4rc1a6b2mzFHgIr6CPaTEguje0u7CSR+b8GxcpFHyTYVEnF1cyQ6F3Fb4OL ZkJCE90QzzCSQMeYvMVKPnzFJGPujSmIRG3Ik5+G/4oiy1t0Q46A7MbM1GbgJmk0nlkq df/8T7nwWJKGVr4kcC6KJZjToy+iKqAY6jWtZ/0bLPlZ4C2WHJBAJpXNcOGhl3vAJZGX iqZw== 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=nJGaB58FVsS5jxtSvE0P91JPilGw8ccwEcTgQkXH45k=; b=M24HcWLqizQwIh1BjxCRy5yfWsnnOmJ5hPthFCh4dIYcbCiqIeP7qd6UO4OeQBpAiF EeaslILuGkPb9qN5Y8iz3/G72ZVRsyrTq8Yct5H2JeGcmzhs9NrGRcCAh7h8eT7Dqprq PkcXSeGKt7WwS9dVhxTsTziESb1Eby0cCq+y2lfW71nVIqAv8OCKjz91U2AVnQeey64X O6UHU5NbIaX2q6JQzwoGpoDW79ttYsxLdKWRt52Hf2inm8XuuE+aWkswHsPJdM+Lw8V8 KzqBGloLN2yLAhet9ZHU89IIkRaW8OWLthfilTHG0GHZwTERSqrDvR/vc//0a2TUFcIt jGuQ== X-Gm-Message-State: AA+aEWaXv2LUtFv7p8fyezVNTGG4wDwf6OA62J3yGgFZuO8ATeWyQx/H v1+dvuFYc+kvTLjs2k+c7WMhgJap X-Google-Smtp-Source: AFSGD/U2yaDUyL8EgWNvtCSRoQpNpRCbhqg+Zko84xFQb66xek+EGLHvpuvyMvTgwl9m4OY+PCS8iA== X-Received: by 2002:a5d:524b:: with SMTP id p11mr7382287wrv.147.1544385901404; Sun, 09 Dec 2018 12:05:01 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id m6sm9196770wrv.24.2018.12.09.12.05.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:05:00 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 3/8] entry: support CE_WT_REMOVE flag in checkout_entry Date: Sun, 9 Dec 2018 20:04:44 +0000 Message-Id: <20181209200449.16342-4-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 'checkout_entry()' currently only supports creating new entries in the working tree, but not deleting them. Add the ability to remove entries at the same time if the entry is marked with the CE_WT_REMOVE flag. Currently this doesn't have any effect, as the CE_WT_REMOVE flag is only used in unpack-tree, however we will make use of this in a subsequent step in the series. Signed-off-by: Thomas Gummerer --- entry.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/entry.c b/entry.c index 3ec148ceee..cd1c6601b6 100644 --- a/entry.c +++ b/entry.c @@ -441,6 +441,13 @@ int checkout_entry(struct cache_entry *ce, static struct strbuf path = STRBUF_INIT; struct stat st; + if (ce->ce_flags & CE_WT_REMOVE) { + if (topath) + BUG("Can't remove entry to a path"); + unlink_entry(ce); + return 0; + } + if (topath) return write_entry(ce, topath, state, 1); From patchwork Sun Dec 9 20:04:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720277 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 6130713BF for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 569542A10E for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B4732A117; Sun, 9 Dec 2018 20:05:15 +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 B77612A10E for ; Sun, 9 Dec 2018 20:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726268AbeLIUFF (ORCPT ); Sun, 9 Dec 2018 15:05:05 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41287 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbeLIUFF (ORCPT ); Sun, 9 Dec 2018 15:05:05 -0500 Received: by mail-wr1-f66.google.com with SMTP id x10so8431220wrs.8 for ; Sun, 09 Dec 2018 12:05:03 -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=FWZv98vQTtRzPGDVRi4ZffwSeHjhvEhAhSPCTlImz8Q=; b=J1j5QCtsuAUtJqUaijVqBiDIndKzHI6RMXgT4Bqg2jfReKADIafmeHwiknEks9EmAh ptvIoA5woNjss/hlPldCkg51LSXHXhbV14ybXKvsspkeG1LGr28/QEvdGoid5Wr3ieLB GOWHnGVzo5kPEKRdHVpz70tg9uxONF4s3mlufVm2LTFz4984H3UiRT3Aq8OSEaaxKOKn VOnyE8JgdBiOYx77m8HetivO65e10cXkfDLNz2pYtpyYWduJ4/uO6Acjdti7S9smCBWN /Dxgdxvp8G5wQw0U/fllf7cgKn+hAgCL3C+yAoVKlrGVzwvF7RgwYUeQ9ygdIIIgAkEW f33Q== 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=FWZv98vQTtRzPGDVRi4ZffwSeHjhvEhAhSPCTlImz8Q=; b=qKhwCKc2v3COD4zyqD75PiNE1Q5+ZKdOeJZ7fh5zq289HVEcndHpEyEvY0Jugwlmwi zjpxWWCfTxbMt0g+FqzIZl4iiZMGl/KL4eyeAjo7+alvFqiUrye/eIC6ci6wXMpRYDcF vykaK6R058FkPeBccPbKb/ThqFBMvQbcEXLwrTjrYoyqsIHLACXD3i2obTbAUSxTvQKm ruXmYYTUaOPTfiwRUln4t8GKMuZIxZUxXEy6TVVgve+yV7ZCrUB87umIFUT+9RCYDqtX F2ugTUV/4oDWPnluMPAasj8l1maBJO53FP/9G1RHfatUo/KCZ5S/PXb2GnO7jYpWOAFn cEQw== X-Gm-Message-State: AA+aEWb3m19mmf8+F065gQSgnhyzjgFPRupxDcqaZaJHYbg/y6a92fyO VN81Nxfj4KBfZHbqHaKeM6nASFiq X-Google-Smtp-Source: AFSGD/WovncDlwt9G6jIu90q7cA/C8LdFkLLVDbgCv13AUbv7IAhXzNyULhpSr2GZD/l/v/xNG3chQ== X-Received: by 2002:a5d:448f:: with SMTP id j15mr7265386wrq.108.1544385902843; Sun, 09 Dec 2018 12:05:02 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id u204sm20523249wmu.30.2018.12.09.12.05.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:05:02 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 4/8] read-cache: add invalidate parameter to remove_marked_cache_entries Date: Sun, 9 Dec 2018 20:04:45 +0000 Message-Id: <20181209200449.16342-5-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 When marking cache entries for removal, and later removing them all at once using 'remove_marked_cache_entries()', cache entries currently have to be invalidated manually in the cache tree and in the untracked cache. Add an invalidate flag to the function. With the flag set, the function will take care of invalidating the path in the cache tree and in the untracked cache. This will be useful in a subsequent commit. Signed-off-by: Thomas Gummerer --- For the two current callsites, unpack-trees seems to do this invalidation itself internally. I don't quite understand why we don't need it in split-index mode though. I assume it's because the cache tree in the main index would already have been invalidated? I didn't have much time to dig, but couldn't produce any failures with it either, so I assume not invalidating paths is the right thing to do here. cache.h | 2 +- read-cache.c | 8 +++++++- split-index.c | 2 +- unpack-trees.c | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cache.h b/cache.h index c1c953e810..1deee48f5b 100644 --- a/cache.h +++ b/cache.h @@ -751,7 +751,7 @@ extern void rename_index_entry_at(struct index_state *, int pos, const char *new /* Remove entry, return true if there are more entries to go. */ extern int remove_index_entry_at(struct index_state *, int pos); -extern void remove_marked_cache_entries(struct index_state *istate); +extern void remove_marked_cache_entries(struct index_state *istate, int invalidate); extern int remove_file_from_index(struct index_state *, const char *path); #define ADD_CACHE_VERBOSE 1 #define ADD_CACHE_PRETEND 2 diff --git a/read-cache.c b/read-cache.c index 4ca81286c0..d86a06acba 100644 --- a/read-cache.c +++ b/read-cache.c @@ -590,13 +590,19 @@ int remove_index_entry_at(struct index_state *istate, int pos) * CE_REMOVE is set in ce_flags. This is much more effective than * calling remove_index_entry_at() for each entry to be removed. */ -void remove_marked_cache_entries(struct index_state *istate) +void remove_marked_cache_entries(struct index_state *istate, int invalidate) { struct cache_entry **ce_array = istate->cache; unsigned int i, j; for (i = j = 0; i < istate->cache_nr; i++) { if (ce_array[i]->ce_flags & CE_REMOVE) { + if (invalidate) { + cache_tree_invalidate_path(istate, + ce_array[i]->name); + untracked_cache_remove_from_index(istate, + ce_array[i]->name); + } remove_name_hash(istate, ce_array[i]); save_or_free_index_entry(istate, ce_array[i]); } diff --git a/split-index.c b/split-index.c index 5820412dc5..8aebc3661b 100644 --- a/split-index.c +++ b/split-index.c @@ -162,7 +162,7 @@ void merge_base_index(struct index_state *istate) ewah_each_bit(si->replace_bitmap, replace_entry, istate); ewah_each_bit(si->delete_bitmap, mark_entry_for_delete, istate); if (si->nr_deletions) - remove_marked_cache_entries(istate); + remove_marked_cache_entries(istate, 0); for (i = si->nr_replacements; i < si->saved_cache_nr; i++) { if (!ce_namelen(si->saved_cache[i])) diff --git a/unpack-trees.c b/unpack-trees.c index e8d1a6ac50..8e6afa924d 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -392,7 +392,7 @@ static int check_updates(struct unpack_trees_options *o) unlink_entry(ce); } } - remove_marked_cache_entries(index); + remove_marked_cache_entries(index, 0); remove_scheduled_dirs(); if (should_update_submodules() && o->update && !o->dry_run) From patchwork Sun Dec 9 20:04:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720279 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 B5AE73E9D for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A87552A0F7 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D0EA2A117; Sun, 9 Dec 2018 20:05:15 +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 D797E2A0F7 for ; Sun, 9 Dec 2018 20:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726277AbeLIUFI (ORCPT ); Sun, 9 Dec 2018 15:05:08 -0500 Received: from mail-wm1-f42.google.com ([209.85.128.42]:36381 "EHLO mail-wm1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbeLIUFI (ORCPT ); Sun, 9 Dec 2018 15:05:08 -0500 Received: by mail-wm1-f42.google.com with SMTP id a18so9200793wmj.1 for ; Sun, 09 Dec 2018 12:05:05 -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=GkfU/TST0+geI2UyE/TLePkOtM0QnqXboBVUDlASKTc=; b=Iq/VxzNeAZJZ4gKDjEgXcmUw8hQruzr6/isJ/q8a+gFqken31uMCKKivpS+j2KSqAi 3XqAkg9QDiH3iYLupDWlX8UbLbc4pTbEvDXvIZgfOHMPrBNMJpjxUDUi3XKB/awkuj++ w/A4Iy1ABbwoTVwW4uuyaNSmTuHf575z0enPngX5VifFbXH7QOsjplj/lrAfNFzKrm2F 09w/whfFyr+gmwNYefBNBA4fVTG+I5ro2PqfPhIE6KwjCFGOm92lV7KYo6czoDG9gy1a JcYMKcumMRNhmHghk2DfTb28dyjLujqNiag8d6CkuHG2izVISUVeHBMIhvj8XijM5Xjr f7QA== 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=GkfU/TST0+geI2UyE/TLePkOtM0QnqXboBVUDlASKTc=; b=DCtPHxyTfcsrWNqArjlFs4yppAHgklIeEx41Gg/t97LNqj/Yjl2Fx8M7KrXIkvwUfr Yi3svuhhwTQ0nexhsbHpYe+fhQEgDDhIp2D0O+2Qo0aIY8jMis8vxt3ANQOACi4LbNGK Xvm4oafjdbuAw2KGFA8zwJQVbUeq1xDBv212/Q+kFaJtotXpcXiPK91yu0qUXCnZB/OL uWLUPc13TC+eCWOBpUeJtfesLrXMlCFem2N1ysXLDRZWMWJdKmQdzkCCu+P0QdZHdT3M m+96DaYhGF4je6UbymLwnqaHU0u/qqQ42eWYUChSmoF4vR/73zoRRzRrTck54sLdCutV wM7A== X-Gm-Message-State: AA+aEWbmjuiB4WA+2KxGzL74HzBR6OaoXrbQ720W34hpFO3KMxIKYryo Ilco46a6Te51JBAqr6gDWIXOMFeH X-Google-Smtp-Source: AFSGD/Xr+0byi4GyV7iv/RPzNshw7E/GxKvqpAbbvlQb30BMlHFuvud8/hR3wLbcJ9PMSSKsLXVCGw== X-Received: by 2002:a1c:3ed0:: with SMTP id l199mr7721379wma.34.1544385904367; Sun, 09 Dec 2018 12:05:04 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id e12sm21227851wmf.22.2018.12.09.12.05.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:05:03 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 5/8] checkout: introduce --{,no-}overlay option Date: Sun, 9 Dec 2018 20:04:46 +0000 Message-Id: <20181209200449.16342-6-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 Currently 'git checkout' is defined as an overlay operation, which means that if in 'git checkout -- []' we have an entry in the index that matches , but that doesn't exist in , that entry will not be removed from the index or the working tree. Introduce a new --{,no-}overlay option, which allows using 'git checkout' in non-overlay mode, thus removing files from the working tree if they do not exist in but match . Note that 'git checkout -p -- []' already works this way, so no changes are needed for the patch mode. We disallow 'git checkout --overlay -p' to avoid confusing users who would expect to be able to force overlay mode in 'git checkout -p' this way. Signed-off-by: Thomas Gummerer --- builtin/checkout.c | 64 +++++++++++++++++++++++++++------- t/t2025-checkout-no-overlay.sh | 47 +++++++++++++++++++++++++ t/t9902-completion.sh | 1 + 3 files changed, 99 insertions(+), 13 deletions(-) create mode 100755 t/t2025-checkout-no-overlay.sh diff --git a/builtin/checkout.c b/builtin/checkout.c index acdafc6e4c..0aef35bbc4 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -44,6 +44,7 @@ struct checkout_opts { int ignore_skipworktree; int ignore_other_worktrees; int show_progress; + int overlay_mode; /* * If new checkout options are added, skip_merge_working_tree * should be updated accordingly. @@ -132,7 +133,8 @@ static int skip_same_name(const struct cache_entry *ce, int pos) return pos; } -static int check_stage(int stage, const struct cache_entry *ce, int pos) +static int check_stage(int stage, const struct cache_entry *ce, int pos, + int overlay_mode) { while (pos < active_nr && !strcmp(active_cache[pos]->name, ce->name)) { @@ -140,6 +142,8 @@ static int check_stage(int stage, const struct cache_entry *ce, int pos) return 0; pos++; } + if (!overlay_mode) + return 0; if (stage == 2) return error(_("path '%s' does not have our version"), ce->name); else @@ -165,7 +169,7 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos) } static int checkout_stage(int stage, const struct cache_entry *ce, int pos, - const struct checkout *state) + const struct checkout *state, int overlay_mode) { while (pos < active_nr && !strcmp(active_cache[pos]->name, ce->name)) { @@ -173,6 +177,10 @@ static int checkout_stage(int stage, const struct cache_entry *ce, int pos, return checkout_entry(active_cache[pos], state, NULL); pos++; } + if (!overlay_mode) { + unlink_entry(ce); + return 0; + } if (stage == 2) return error(_("path '%s' does not have our version"), ce->name); else @@ -302,15 +310,29 @@ static int checkout_paths(const struct checkout_opts *opts, ce->ce_flags &= ~CE_MATCHED; if (!opts->ignore_skipworktree && ce_skip_worktree(ce)) continue; - if (opts->source_tree && !(ce->ce_flags & CE_UPDATE)) - /* - * "git checkout tree-ish -- path", but this entry - * is in the original index; it will not be checked - * out to the working tree and it does not matter - * if pathspec matched this entry. We will not do - * anything to this entry at all. - */ - continue; + if (opts->source_tree && !(ce->ce_flags & CE_UPDATE)) { + if (!opts->overlay_mode && + ce_path_match(&the_index, ce, &opts->pathspec, ps_matched)) { + /* + * "git checkout --no-overlay -- path", + * and the path is not in tree-ish, but is in + * the current index, which means that it should + * be removed. + */ + ce->ce_flags |= CE_MATCHED | CE_REMOVE | CE_WT_REMOVE; + continue; + } else { + /* + * "git checkout tree-ish -- path", but this + * entry is in the original index; it will not + * be checked out to the working tree and it + * does not matter if pathspec matched this + * entry. We will not do anything to this entry + * at all. + */ + continue; + } + } /* * Either this entry came from the tree-ish we are * checking the paths out of, or we are checking out @@ -348,7 +370,7 @@ static int checkout_paths(const struct checkout_opts *opts, if (opts->force) { warning(_("path '%s' is unmerged"), ce->name); } else if (opts->writeout_stage) { - errs |= check_stage(opts->writeout_stage, ce, pos); + errs |= check_stage(opts->writeout_stage, ce, pos, opts->overlay_mode); } else if (opts->merge) { errs |= check_stages((1<<2) | (1<<3), ce, pos); } else { @@ -375,12 +397,14 @@ static int checkout_paths(const struct checkout_opts *opts, continue; } if (opts->writeout_stage) - errs |= checkout_stage(opts->writeout_stage, ce, pos, &state); + errs |= checkout_stage(opts->writeout_stage, ce, pos, &state, opts->overlay_mode); else if (opts->merge) errs |= checkout_merged(pos, &state); pos = skip_same_name(ce, pos) - 1; } } + remove_marked_cache_entries(&the_index, 1); + remove_scheduled_dirs(); errs |= finish_delayed_checkout(&state); if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) @@ -542,6 +566,11 @@ static int skip_merge_working_tree(const struct checkout_opts *opts, * opts->show_progress only impacts output so doesn't require a merge */ + /* + * opts->overlay_mode cannot be used with switching branches so is + * not tested here + */ + /* * If we aren't creating a new branch any changes or updates will * happen in the existing branch. Since that could only be updating @@ -1178,6 +1207,10 @@ static int checkout_branch(struct checkout_opts *opts, die(_("'%s' cannot be used with switching branches"), "--patch"); + if (!opts->overlay_mode) + die(_("'%s' cannot be used with switching branches"), + "--no-overlay"); + if (opts->writeout_stage) die(_("'%s' cannot be used with switching branches"), "--ours/--theirs"); @@ -1266,6 +1299,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) "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")), OPT_END(), }; @@ -1274,6 +1308,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) opts.overwrite_ignore = 1; opts.prefix = prefix; opts.show_progress = -1; + opts.overlay_mode = -1; git_config(git_checkout_config, &opts); @@ -1297,6 +1332,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) 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) + die(_("-p and --overlay are mutually exclusive")); + /* * From here on, new_branch will contain the branch to be checked out, * and new_branch_force and new_orphan_branch will tell us which one of diff --git a/t/t2025-checkout-no-overlay.sh b/t/t2025-checkout-no-overlay.sh new file mode 100755 index 0000000000..3575321382 --- /dev/null +++ b/t/t2025-checkout-no-overlay.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +test_description='checkout --no-overlay -- ' + +. ./test-lib.sh + +test_expect_success 'setup' ' + git commit --allow-empty -m "initial" +' + +test_expect_success 'checkout --no-overlay deletes files not in ' ' + >file && + mkdir dir && + >dir/file1 && + git add file dir/file1 && + git checkout --no-overlay HEAD -- file && + test_path_is_missing file && + test_path_is_file dir/file1 +' + +test_expect_success 'checkout --no-overlay removing last file from directory' ' + git checkout --no-overlay HEAD -- dir/file1 && + test_path_is_missing dir +' + +test_expect_success 'checkout -p --overlay is disallowed' ' + test_must_fail git checkout -p --overlay HEAD 2>actual && + test_i18ngrep "fatal: -p and --overlay are mutually exclusive" actual +' + +test_expect_success '--no-overlay --theirs with M/D conflict deletes file' ' + test_commit file1 file1 && + test_commit file2 file2 && + git rm --cached file1 && + echo 1234 >file1 && + F1=$(git rev-parse HEAD:file1) && + F2=$(git rev-parse HEAD:file2) && + { + echo "100644 $F1 1 file1" && + echo "100644 $F2 2 file1" + } | git update-index --index-info && + test_path_is_file file1 && + git checkout --theirs --no-overlay -- file1 && + test_path_is_missing file1 +' + +test_done diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 175f83d704..a3fd9a9630 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1436,6 +1436,7 @@ test_expect_success 'double dash "git checkout"' ' --progress Z --no-quiet Z --no-... Z + --overlay Z EOF ' From patchwork Sun Dec 9 20:04:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720287 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 5ABA313BF for ; Sun, 9 Dec 2018 20:05:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D6532A0FC for ; Sun, 9 Dec 2018 20:05:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 420312A101; Sun, 9 Dec 2018 20:05:17 +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 0459C2A102 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726286AbeLIUFI (ORCPT ); Sun, 9 Dec 2018 15:05:08 -0500 Received: from mail-wr1-f51.google.com ([209.85.221.51]:44984 "EHLO mail-wr1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbeLIUFI (ORCPT ); Sun, 9 Dec 2018 15:05:08 -0500 Received: by mail-wr1-f51.google.com with SMTP id z5so8412064wrt.11 for ; Sun, 09 Dec 2018 12:05: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=GtPGQIh0OUkZCwDoPnRmfu8zS4UwjMxygBHJe/8XWCA=; b=bNUi52dzmsuK7O0NS+Tz7TfhR5cxKYve0nOSIcB4EYCyq1EXYwc1n3HuSjGx2j97/s PkrJQ7QqYx7wDjYju450ksHLFwyEZ1t6du3jG7FjraZzwjIk/RB0x4Po6klDO4FLnniW aCHWwWGIjO8Wej42ZNc7fp2cqaueSAbRequw/+ITyq6EWBExSkSDuZcSjZyXrGYTH0g9 wXDg9Ni1hLEZpDi0QXKxbw1trGciN1A41rutWkyMhcKp0oyuCBrAHFa0+b0FaP3BGbGG a0qnpiF0iXR5Kw6X4qSrZBLOhnwrAKvQFZlkmfHvv+RjjQfmMvcqEP5iVElTzgWJ3wOM 9hUQ== 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=GtPGQIh0OUkZCwDoPnRmfu8zS4UwjMxygBHJe/8XWCA=; b=uWVpbM3xzMAV+ddpyccPrVbQKvH2xAYASqXsrGCtuPqTSXWuM+v5X8HFq65xSmV7w7 dBKzh1LQgbw1ogdYyt4IKKR1DkY5r3pB7D9S9QeSnAh5dweK0g6Dk31RDVXHqH+o1DON JznfSPyX/OFzB4UkBGgTZxcvQZTJATQGOmNh2jwgtFkMKTA09fT9Wq/IL5GY93pC9p7W DswCV8MkVfCYVAVxSg6qeIAHtgH1JYI0bbPUbSnZUvkIukKxiyGhO2LfPH6Txnx/CD4T 2vbGV/m01aI17sGP5cIyJnCSL1TsxLMuoWcJHGzhRt45nlmVLqlw0rdxDm9YbE9R2VEj AZZg== X-Gm-Message-State: AA+aEWZkqkP+dMGJBAq8oKIyamAybKjiLSxMvOevmT8hIxWYchxTkpdE SkOJhiV2EsGk4PFVwsK/N91+YGMF X-Google-Smtp-Source: AFSGD/Wi5+lwDyoT+v1R8dM29x5rpy+7ncq6QVWW8AUOjjUcgFD8fsGC7QOqE7oHO8PVcitAUv+l3A== X-Received: by 2002:adf:c505:: with SMTP id q5mr7575352wrf.84.1544385905976; Sun, 09 Dec 2018 12:05:05 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id k19sm19271304wre.5.2018.12.09.12.05.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:05:05 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 6/8] checkout: add --cached option Date: Sun, 9 Dec 2018 20:04:47 +0000 Message-Id: <20181209200449.16342-7-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 Add a new --cached option to git checkout, which works only on the index, but not the working tree, similar to what 'git reset -- ... does. Indeed the tests are adapted from the 'git reset' tests. In the longer term the idea is to potentially deprecate 'git reset -- ...', so the 'git reset' command becomes only about re-pointing the HEAD, and not also about copying entries from to the index. Note that 'git checkout' by default works in overlay mode, meaning files that match the pathspec that don't exist in , but exist in the index would not be removed. 'git checkout --no-overlay --cached' can be used to get the same behaviour as 'git reset -- '. One thing this patch doesn't currently deal with is conflicts. Currently 'git checkout --{ours,theirs} -- ' doesn't do anything with the index, so the --cached option just mirrors that behaviour. But given it doesn't even deal with conflicts, the '--cached' option doesn't make much sense when no is given. As it operates only on the index, it's always a no-op if no tree-ish is given. Signed-off-by: Thomas Gummerer --- Maybe we can just disallow --cached without given for now, and possibly later allow it with some different behaviour for conflicts, not sure what the best way forward here is. We can also just make it update the index as appropriate, and have it behave different than 'git checkout' curerntly does when handling conflicts? builtin/checkout.c | 26 ++++++++-- t/t2016-checkout-patch.sh | 8 +++ t/t2026-checkout-cached.sh | 103 +++++++++++++++++++++++++++++++++++++ t/t9902-completion.sh | 1 + 4 files changed, 135 insertions(+), 3 deletions(-) create mode 100755 t/t2026-checkout-cached.sh diff --git a/builtin/checkout.c b/builtin/checkout.c index 0aef35bbc4..6ba85e9de5 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -45,6 +45,7 @@ struct checkout_opts { int ignore_other_worktrees; int show_progress; int overlay_mode; + int cached; /* * If new checkout options are added, skip_merge_working_tree * should be updated accordingly. @@ -288,6 +289,10 @@ static int checkout_paths(const struct checkout_opts *opts, die(_("Cannot update paths and switch to branch '%s' at the same time."), opts->new_branch); + if (opts->patch_mode && opts->cached) + return run_add_interactive(revision, "--patch=reset", + &opts->pathspec); + if (opts->patch_mode) return run_add_interactive(revision, "--patch=checkout", &opts->pathspec); @@ -319,7 +324,9 @@ static int checkout_paths(const struct checkout_opts *opts, * the current index, which means that it should * be removed. */ - ce->ce_flags |= CE_MATCHED | CE_REMOVE | CE_WT_REMOVE; + ce->ce_flags |= CE_MATCHED | CE_REMOVE; + if (!opts->cached) + ce->ce_flags |= CE_WT_REMOVE; continue; } else { /* @@ -392,6 +399,9 @@ static int checkout_paths(const struct checkout_opts *opts, for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; if (ce->ce_flags & CE_MATCHED) { + if (opts->cached) { + continue; + } if (!ce_stage(ce)) { errs |= checkout_entry(ce, &state, NULL); continue; @@ -571,6 +581,11 @@ static int skip_merge_working_tree(const struct checkout_opts *opts, * not tested here */ + /* + * opts->cached cannot be used with switching branches so is + * not tested here + */ + /* * If we aren't creating a new branch any changes or updates will * happen in the existing branch. Since that could only be updating @@ -1207,9 +1222,13 @@ static int checkout_branch(struct checkout_opts *opts, die(_("'%s' cannot be used with switching branches"), "--patch"); - if (!opts->overlay_mode) + if (opts->overlay_mode != -1) + die(_("'%s' cannot be used with switching branches"), + "--overlay/--no-overlay"); + + if (opts->cached) die(_("'%s' cannot be used with switching branches"), - "--no-overlay"); + "--cached"); if (opts->writeout_stage) die(_("'%s' cannot be used with switching branches"), @@ -1300,6 +1319,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) 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")), + OPT_BOOL(0, "cached", &opts.cached, N_("work on the index only")), OPT_END(), }; diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh index 47aeb0b167..e8774046e0 100755 --- a/t/t2016-checkout-patch.sh +++ b/t/t2016-checkout-patch.sh @@ -108,6 +108,14 @@ test_expect_success PERL 'path limiting works: foo inside dir' ' verify_state dir/foo head head ' +test_expect_success PERL 'git checkout --cached -p' ' + set_and_save_state dir/foo work work && + test_write_lines n y | git checkout --cached -p >output && + verify_state dir/foo work head && + verify_saved_state bar && + test_i18ngrep "Unstage" output +' + test_expect_success PERL 'none of this moved HEAD' ' verify_saved_head ' diff --git a/t/t2026-checkout-cached.sh b/t/t2026-checkout-cached.sh new file mode 100755 index 0000000000..1b66192727 --- /dev/null +++ b/t/t2026-checkout-cached.sh @@ -0,0 +1,103 @@ +#!/bin/sh + +test_description='checkout --cached ' + +. ./test-lib.sh + +test_expect_success 'checkout --cached ' ' + echo 1 >file1 && + echo 2 >file2 && + git add file1 file2 && + test_tick && + git commit -m files && + git rm file2 && + echo 3 >file3 && + echo 4 >file1 && + git add file1 file3 && + git checkout --cached HEAD -- file1 file2 && + test_must_fail git diff --quiet && + + cat >expect <<-\EOF && + diff --git a/file1 b/file1 + index d00491f..b8626c4 100644 + --- a/file1 + +++ b/file1 + @@ -1 +1 @@ + -1 + +4 + diff --git a/file2 b/file2 + deleted file mode 100644 + index 0cfbf08..0000000 + --- a/file2 + +++ /dev/null + @@ -1 +0,0 @@ + -2 + EOF + git diff >actual && + test_cmp expect actual && + + cat >expect <<-\EOF && + diff --git a/file3 b/file3 + new file mode 100644 + index 0000000..00750ed + --- /dev/null + +++ b/file3 + @@ -0,0 +1 @@ + +3 + EOF + git diff --cached >actual && + test_cmp expect actual +' + +test_expect_success 'checking out an unmodified path is a no-op' ' + git reset --hard && + git checkout --cached HEAD -- file1 && + git diff-files --exit-code && + git diff-index --cached --exit-code HEAD +' + +test_expect_success 'checking out specific path that is unmerged' ' + test_commit file3 file3 && + git rm --cached file2 && + echo 1234 >file2 && + F1=$(git rev-parse HEAD:file1) && + F2=$(git rev-parse HEAD:file2) && + F3=$(git rev-parse HEAD:file3) && + { + echo "100644 $F1 1 file2" && + echo "100644 $F2 2 file2" && + echo "100644 $F3 3 file2" + } | git update-index --index-info && + git ls-files -u && + git checkout --cached HEAD file2 && + test_must_fail git diff --quiet && + git diff-index --exit-code --cached HEAD +' + +test_expect_success '--cached without --no-overlay does not remove entry from index' ' + test_must_fail git checkout --cached HEAD^ file3 && + git ls-files --error-unmatch -- file3 +' + +test_expect_success 'file is removed from the index with --no-overlay' ' + git checkout --cached --no-overlay HEAD^ file3 && + test_path_is_file file3 && + test_must_fail git ls-files --error-unmatch -- file3 +' + +test_expect_success 'test checkout --cached --no-overlay at given paths' ' + mkdir sub && + >sub/file1 && + >sub/file2 && + git update-index --add sub/file1 sub/file2 && + T=$(git write-tree) && + git checkout --cached --no-overlay HEAD sub/file2 && + test_must_fail git diff --quiet && + U=$(git write-tree) && + echo "$T" && + echo "$U" && + test_must_fail git diff-index --cached --exit-code "$T" && + test "$T" != "$U" +' + +test_done diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index a3fd9a9630..cbc304ace8 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1437,6 +1437,7 @@ test_expect_success 'double dash "git checkout"' ' --no-quiet Z --no-... Z --overlay Z + --cached Z EOF ' From patchwork Sun Dec 9 20:04:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720291 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 E874C18A7 for ; Sun, 9 Dec 2018 20:05:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA42F2A0F7 for ; Sun, 9 Dec 2018 20:05:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE6BD2A0FC; Sun, 9 Dec 2018 20:05:17 +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 2493D2A106 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726292AbeLIUFL (ORCPT ); Sun, 9 Dec 2018 15:05:11 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38142 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbeLIUFK (ORCPT ); Sun, 9 Dec 2018 15:05:10 -0500 Received: by mail-wr1-f66.google.com with SMTP id v13so8455983wrw.5 for ; Sun, 09 Dec 2018 12:05:08 -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=stC4U0fS6L3+UPWXmWTRD/EWbWoBknt4Y6k9/VcGR3U=; b=Cs63REAtdAZrBzKj5lEl0OJler3Bs5UB617hxxFUPn1VN2FsCcmrrEVp/Ni0CGyEuY ct8izSoMG0ghej+mTq0xhUmFYSWhthILE06ntGh7NjGSetsWHd9AS+uGU5btEdI46ML/ /NeTOn7EUBLyR1oSa0fZEilIWTCLEa5YzQd9uvbtEzGHpRZTnK46gh2UOCWV9Lf7mnYg vTuUdKuiwxeeL6cmzPf3lA+v5tDYKlPCW2fg7fMynb6SyvvHuSSch+LOBnTDD/rCzOiG XqoAX3J9A7kJpyzZOVzx/oYPmMQQnzIk8xJYzHF9gQU/QM2H5SIuUXVjPEHYlXHn8y9v jdNg== 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=stC4U0fS6L3+UPWXmWTRD/EWbWoBknt4Y6k9/VcGR3U=; b=iLogtRuOHCZP1TLtYH7wWoYEfa05AxQZj1JDtQeeBl0kRgdevB6YP5GvwOmE7Nvirn weBpTDB9sVYtZ6uZZ0eOeILA/rAmu+lOr8ZvyTL+RPiZ7IiaW9R+0TRI+A7AipEN4x2G aHlS51y6xiZaISJ6CmICOVn9MZYTA8hxYCEU81oM8BuMK1yggRRVwxXPxsdnbSTD8jD3 ihjj0uuhf189CRgSCiKYXJ1EpWl2XDTR0ShUAEWqo+z6wO9cxJPYqq2Y4I7fJxC2x3vR m77Pv8fVbYLuNeGjilnoObN1oNHLoixbgzoq9R5iccWtvapbXBnvNXNNRhBr9/JrmOnO Qz+Q== X-Gm-Message-State: AA+aEWbxp2YyhYngrVIKxqJBCF5z7gbEXzKmNsUoScjKvEsMlJdrc4ZD qfNHNcCA4JWbp3RNJgao+t9C4sst X-Google-Smtp-Source: AFSGD/VnaUHgN2zcfIpxC9FmYmWuAei2kh1swCWNkGQ/8gkMoZZuP8ZsgwB13vFfkqaTKRyxRf/m+Q== X-Received: by 2002:adf:f785:: with SMTP id q5mr8250594wrp.9.1544385907649; Sun, 09 Dec 2018 12:05:07 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id n127sm12245169wmd.20.2018.12.09.12.05.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:05:06 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 7/8] checkout: allow ignoring unmatched pathspec Date: Sun, 9 Dec 2018 20:04:48 +0000 Message-Id: <20181209200449.16342-8-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 Currently when 'git checkout -- ...' is invoked with multiple pathspecs, where one or more of the pathspecs don't match anything, checkout errors out. This can be inconvenient in some cases, such as when using git checkout from a script. Introduce a new --ignore-unmatched option, which which allows us to ignore a non-matching pathspec instead of erroring out. In a subsequent commit we're going to start using 'git checkout' in 'git stash' and are going to make use of this feature. Signed-off-by: Thomas Gummerer --- builtin/checkout.c | 10 +++++++++- t/t2022-checkout-paths.sh | 9 +++++++++ t/t9902-completion.sh | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 6ba85e9de5..7e7b5cd1d3 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -46,6 +46,7 @@ struct checkout_opts { int show_progress; int overlay_mode; int cached; + int ignore_unmatched; /* * If new checkout options are added, skip_merge_working_tree * should be updated accordingly. @@ -358,7 +359,8 @@ static int checkout_paths(const struct checkout_opts *opts, ce->ce_flags |= CE_MATCHED; } - if (report_path_error(ps_matched, &opts->pathspec, opts->prefix)) { + if (!opts->ignore_unmatched && + report_path_error(ps_matched, &opts->pathspec, opts->prefix)) { free(ps_matched); return 1; } @@ -586,6 +588,11 @@ static int skip_merge_working_tree(const struct checkout_opts *opts, * not tested here */ + /* + * opts->ignore_unmatched cannot be used with switching branches so is + * not tested here + */ + /* * If we aren't creating a new branch any changes or updates will * happen in the existing branch. Since that could only be updating @@ -1320,6 +1327,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "progress", &opts.show_progress, N_("force progress reporting")), OPT_BOOL(0, "overlay", &opts.overlay_mode, N_("use overlay mode")), OPT_BOOL(0, "cached", &opts.cached, N_("work on the index only")), + OPT_BOOL(0, "ignore-unmatched", &opts.ignore_unmatched, N_("don't error on unmatched pathspecs")), OPT_END(), }; diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh index fc3eb43b89..b44cdf7b63 100755 --- a/t/t2022-checkout-paths.sh +++ b/t/t2022-checkout-paths.sh @@ -78,4 +78,13 @@ test_expect_success 'do not touch files that are already up-to-date' ' test_cmp expect actual ' +test_expect_success 'checkout --ignore-unmatched' ' + test_commit file1 && + echo changed >file1.t && + git checkout --ignore-unmatched -- file1.t unknown-file && + echo file1 >expect && + test_cmp expect file1.t + +' + test_done diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index cbc304ace8..475debcf95 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1438,6 +1438,7 @@ test_expect_success 'double dash "git checkout"' ' --no-... Z --overlay Z --cached Z + --ignore-unmatched Z EOF ' From patchwork Sun Dec 9 20:04:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 10720281 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 C7C1318B8 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBBCD2A112 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B03092A128; Sun, 9 Dec 2018 20:05:15 +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 44B222A112 for ; Sun, 9 Dec 2018 20:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726296AbeLIUFN (ORCPT ); Sun, 9 Dec 2018 15:05:13 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53248 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbeLIUFM (ORCPT ); Sun, 9 Dec 2018 15:05:12 -0500 Received: by mail-wm1-f65.google.com with SMTP id y1so8874582wmi.3 for ; Sun, 09 Dec 2018 12:05:10 -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=cs57XMhhnD3KJ2N17/GozYJKucxi7bms2I7nY+6b5bM=; b=tFIwkG8pl5REylpKpEZYIHs10FehCvyxy5w/fg4164yZeFgwFbqINFA5LdNm2UyD2v p23M26cXOHmxzDWLrLApg8xAr+99UVoa6dtsCwFzyvuGIHxL22uffTXjOZPe+96s/zNR Tl5LArFb7IiNmimeYhR5U7mKaD4wPJUVtycnzomQBgCbXujKsuCdgDzvT63aK/jLRo0q puEpCydBo5v4eoSFDZS2T2xpZDu9+uM/GrG5a39OIOxt6RLowMoTDCFx1nzjd75mak4d 4OhVte6bG+ddJHFjMBQ4KBuPK5dWK2BhrSxgY3pkA0AB8p8okUSDd/J/BJr2GFpAHjps 0wFQ== 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=cs57XMhhnD3KJ2N17/GozYJKucxi7bms2I7nY+6b5bM=; b=rLAlmgmJyyo+TAjJkj9jabeHA4k2Sr4Z2e/hjGmR/5fb7N0REpDP4iqcdxwga7dAq2 SrzZKE+QEpjwiOMJgUUsj+zAJZtjFevVB/fg86ytmekd8/6e9sRd0486ZFX0CWR42ChI O8678vhBE1t//7+VGV3kttN2CwCPVHYJxgTOyWqmTqviUBDURosjq8g2QWfpWhW5rzcZ gB1o30krIVpfJEYM6pmGMvOl29+lWg6czMmpq3en2K1KdAa4cKFzTvli793zytzker+h KVaAfsZ4uPbPvCNRAOyXVzc7FOMgzTDbAUcFwLC4Z+HdudEOrIbbjaHBEknbf6XiPkiD Jm3w== X-Gm-Message-State: AA+aEWZ6U3PwMTRXTnwMXvt6m0tdbLVYKEps0iTmJIDZcFpqYxBD1odf +Gbe2LyX58/OOtlkt6VssWL03W7J X-Google-Smtp-Source: AFSGD/Uk7aCoTQn7WIJMtq5U7JzBCF0XR9G2uVSU/9tuy3f7HLjZySUPxdsw0zfNcK7HGewwCZQ3+w== X-Received: by 2002:a1c:1593:: with SMTP id 141mr2235820wmv.85.1544385909050; Sun, 09 Dec 2018 12:05:09 -0800 (PST) Received: from localhost ([2.24.105.121]) by smtp.gmail.com with ESMTPSA id y145sm7001647wmd.30.2018.12.09.12.05.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Dec 2018 12:05:08 -0800 (PST) From: Thomas Gummerer To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmc=?= =?utf-8?b?4buNYyBEdXk=?= , Elijah Newren , Thomas Gummerer Subject: [PATCH 8/8] stash: use git checkout --no-overlay Date: Sun, 9 Dec 2018 20:04:49 +0000 Message-Id: <20181209200449.16342-9-t.gummerer@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: <20181209200449.16342-1-t.gummerer@gmail.com> References: <20181209200449.16342-1-t.gummerer@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 Now that we have 'git checkout --no-overlay', we can use it in git stash, making the codepaths for 'git stash push' with and without pathspec more similar, and thus easier to follow. Signed-off-by: Thomas Gummerer --- As mentioned in the cover letter, not sure if we want to apply this now. There are two reasons I did this: - Showing the new functionality of git checkout - Increased test coverage, as we are running the new code with all git stash tests for free, which helped look at some cases that I was missing initially. git-stash.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index 94793c1a91..67be04d996 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -314,19 +314,15 @@ push_stash () { if test -z "$patch_mode" then - test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION= - if test -n "$untracked" && test $# = 0 + test "$untracked" = "all" && CLEAN_X_OPTION=-X || CLEAN_X_OPTION= + if test -n "$untracked" then - git clean --force --quiet -d $CLEAN_X_OPTION + git clean --force --quiet -d $CLEAN_X_OPTION -- "$@" fi if test $# != 0 then - test -z "$untracked" && UPDATE_OPTION="-u" || UPDATE_OPTION= - test "$untracked" = "all" && FORCE_OPTION="--force" || FORCE_OPTION= - git add $UPDATE_OPTION $FORCE_OPTION -- "$@" - git diff-index -p --cached --binary HEAD -- "$@" | - git apply --index -R + git checkout --quiet --no-overlay --ignore-unmatched HEAD -- "$@" else git reset --hard -q fi