From patchwork Sat Mar 14 07:11:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B5666CA for ; Sun, 15 Mar 2020 02:26:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B50B20578 for ; Sun, 15 Mar 2020 02:26:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k/411pAL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727367AbgCOC0b (ORCPT ); Sat, 14 Mar 2020 22:26:31 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39810 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbgCOC0a (ORCPT ); Sat, 14 Mar 2020 22:26:30 -0400 Received: by mail-ed1-f65.google.com with SMTP id d1so4261452edu.6 for ; Sat, 14 Mar 2020 19:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=BmKV7oFN4iQWK0H2ANuyeOer2R1yN9d+6RLRtDWCvTg=; b=k/411pALeQgydbym+Obv+1NPBdrudyc6sD2AIyEIvFDcccyXTxyyNatZ4oU7+F6gLf f4b/ryqx3JqgAHwiYRCNQRK4if2OKEqdC0yhc2XRZ+i3vvmUZO7mmiIBH+7+raAiKWQn 6oTotUZoIYzuuNI7Yv83/6Uk5V7R0iq13DUrgEbylFfJ1sy1HB9a6DXTlHYrFDKsPjAK +7TqQzMNdesJpClGRmBr81qdaQBEvvPK647VvOrXUN/jzCemyeIZOpYhuCKC8VQkpE7S YHXK8UcVJJwO7x5G9ArEaJYmYAyRi2fwQCk7V4Q2HjxLdcqkogtmIQWaJAaI83F3ndzB ja0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=BmKV7oFN4iQWK0H2ANuyeOer2R1yN9d+6RLRtDWCvTg=; b=onpym3vWJBW0ecn1u+Rcy1W/ycWtIzxQAreWtbptD4zywF/ViNeGxypQ1O1tSt8lb6 EoYMcvd8HUDKRKlwT3hrxDJRZnW5flq4eq10VOmDC9syLGwz+ZWM4pSRobQbWF9YwhrH H5tmU3ITIW5m8c4RfTX9YMkeQvOgYHLGc7loE+Ia/v+pgFur3cH8pbm68MdJXohFjFd3 f2QIPN8SjAUJogmjclQo8ytBZlDm+nWYkSqxCBHdDv6kfF/xEFSYEYocpF2BDjAr0Adl f3ULTx3e5sZY2/kk+mGT4s2s6daWaamDolFx2noc6uq/YVNUmsZcRU/XhMorHxCzd8be Q1mg== X-Gm-Message-State: ANhLgQ2Y7meIPNbq5zx7zL/J/s5KoKMpDoCEvoX64D+zQjoSTUNGaXTP 0I9P2lX43R8EZDnbaC3+M2/sU1mQ X-Google-Smtp-Source: ADFU+vu7v7GJy0yfYRyWybVj9xTqgfep8YGxMhmirfLjO0UsnNEJ/Si/jha2FSKxYbXxDGqC09jakg== X-Received: by 2002:a17:906:c358:: with SMTP id ci24mr14227992ejb.128.1584169895625; Sat, 14 Mar 2020 00:11:35 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d9sm1459315ejc.79.2020.03.14.00.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:35 -0700 (PDT) Message-Id: <9ab9a9d60371d0a54b2a8fc10512ad6d8daaad43.1584169893.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:27 +0000 Subject: [PATCH 1/7] unpack-trees: fix minor typo in comment Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Signed-off-by: Elijah Newren --- unpack-trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpack-trees.c b/unpack-trees.c index 1ecdab33040..0d0eec0221e 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1618,7 +1618,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options /* * Sparse checkout loop #2: set NEW_SKIP_WORKTREE on entries not in loop #1 - * If the will have NEW_SKIP_WORKTREE, also set CE_SKIP_WORKTREE + * If they will have NEW_SKIP_WORKTREE, also set CE_SKIP_WORKTREE * so apply_sparse_checkout() won't attempt to remove it from worktree */ mark_new_skip_worktree(o->pl, &o->result, From patchwork Sat Mar 14 07:11:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A944159A for ; Sun, 15 Mar 2020 04:25:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32DEC20724 for ; Sun, 15 Mar 2020 04:25:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fSE+5tz6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726278AbgCOEZv (ORCPT ); Sun, 15 Mar 2020 00:25:51 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37199 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbgCOEZv (ORCPT ); Sun, 15 Mar 2020 00:25:51 -0400 Received: by mail-wr1-f68.google.com with SMTP id 6so17054678wre.4 for ; Sat, 14 Mar 2020 21:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=pNTZUDjJPBSKm8DnqvbjiMFhIXpHTgA3IEGTERjokJ4=; b=fSE+5tz6rtk2NKwAR39b5YZ4uPIs4fXzQFbmADjVsAknKUtcrGBatnVwQeJ+ZwX176 2L7cOpJKV4kmaQUSJkIBcNA8A7xE0Sf0oBo9LbuLXNy/2IkYsLbrq7QI84H9GZ9MORPm VV7T7HDa+uF/Bl3Uen99ikjaOCf1wjNjLZ1JHn0EofbOXuqjPiN0OiK7VudnrWtRGoZ7 WSIQs/gQwYQWcF340qrFjD48rRSgv2G8VweEADlplLYSop+0hnaUugX3CgUWGD5FUbJZ QbW4icDoQL5tanyoWeXkKPQlIVKgRvbFLxzHfFqJHRCIpHeqnoor5G4huKqw5INx2nJh wceA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=pNTZUDjJPBSKm8DnqvbjiMFhIXpHTgA3IEGTERjokJ4=; b=eqmvssnkDeh01WQme4zJYa1NvoEGL02JqptzE4K/9VS1hA94Bt1UNVNdodr+2iUjNw pKVcz8ikU7THOgGTDeo1H6yRjjP4SSySubYTXrOprBxEnBKydsn75lQhWLCdR6JmWMP7 S1y0yC95z53jgqR3QfqHRKhDg0QpHnvXIpKCC/JmoZH7bESsKdswniwJMiJIG8Fn43na b7SBM1Q64i8TECBR5239I2dQrZdRaWUclXpqwDXnlIOu3+hAw/iidBjhQZIWZ2A+Cc+R 5/+/IN2O1EYHes/GKXZafoAM63nrjoJhQMcooeZSXW2fRJHCRxMZN6V7OQIc4EJ324JS vDcg== X-Gm-Message-State: ANhLgQ3AWouFTpqIod7Z3oENAg59K8LUj98UYMowB2k0oRn3en4j8OU7 Y84VSil4ozSUZIM2yak7P5XADyju X-Google-Smtp-Source: ADFU+vsJImX/OezvZGW1bGU8Ks9wne1GZIdWBPVtn4EM/aZLRyRyg/DsUD/Ok4OVy5VKQ1RVu0ssmw== X-Received: by 2002:a17:906:b888:: with SMTP id hb8mr14478082ejb.166.1584169896299; Sat, 14 Mar 2020 00:11:36 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id aq2sm1702998ejc.9.2020.03.14.00.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:35 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:28 +0000 Subject: [PATCH 2/7] t1091: make some tests a little more defensive against failures Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Signed-off-by: Elijah Newren --- t/t1091-sparse-checkout-builtin.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index 44a91205d60..8607a8e6d1a 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -278,6 +278,7 @@ test_expect_success 'cone mode: add parent path' ' ' test_expect_success 'revert to old sparse-checkout on bad update' ' + test_when_finished git -C repo sparse-checkout disable && test_when_finished git -C repo reset --hard && git -C repo sparse-checkout set deep && echo update >repo/deep/deeper2/a && @@ -328,6 +329,7 @@ test_expect_success 'sparse-checkout (init|set|disable) fails with dirty status' ' test_expect_success 'cone mode: set with core.ignoreCase=true' ' + rm repo/.git/info/sparse-checkout && git -C repo sparse-checkout init --cone && git -C repo -c core.ignoreCase=true sparse-checkout set folder1 && cat >expect <<-\EOF && From patchwork Sat Mar 14 07:11:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CB5C921 for ; Sun, 15 Mar 2020 03:13:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DED9820724 for ; Sun, 15 Mar 2020 03:13:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p+LtjR0N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbgCODNP (ORCPT ); Sat, 14 Mar 2020 23:13:15 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:45681 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbgCODNO (ORCPT ); Sat, 14 Mar 2020 23:13:14 -0400 Received: by mail-ed1-f67.google.com with SMTP id h62so17417870edd.12 for ; Sat, 14 Mar 2020 20:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=t2TKyN5RTnXDltMr66E5/PQPABoY3muWSJHQFaxKrAQ=; b=p+LtjR0NOBnwSem6/UJbSoBIFKQfVZEIUHC/xWbmIhuDz+qy1h1RuEkqm4qrAnC/uS Q+OKX72qe7uqxd5zdeDvoIl74ZBvuUD7BmXdynP395g7NQZAP5bFASd4KG6pYH5CaRvG S/UpL37QGqtpxxkI/CK33g1w7XxoNuNXcDw0NiUgxY8bpxtFicJ0lN6XllRCpYrN+OQW YI13qZKZ9AWd4uPvSbzKXvGdnLtNV8cpYVv5kIzHA4yF+9zP6jeBjGB99JKlMjdmTbVi pgSBHuzhlB0pGt6veOfIGzmrvwkC4wNZb8vS2SeC7IAVYMU7UvNNRWhVhxvibUXakLno KuzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=t2TKyN5RTnXDltMr66E5/PQPABoY3muWSJHQFaxKrAQ=; b=nCogjiZtEAGueMnv3MbUrZhH6S0NAce0yjvWUoCvf7MMYP7sn8sTBuCe2HyDaELwa1 8JePppaiDFUEEj/6Tl/S8rqJsd9O155YBtmjy8D9FLkZIvZY5rscUbZs3QaU+EmV0XAR YoDM/wQib7Wa/WApkvPcFShsfsYn4EOaMHFETJfQzijgPIrjH3XPo40CJkQEGJZfZd4X S2TDM55AJSJPhZtsj+MzgbVFMubbk913f0ijdQEZ7lXReNHLr8q6NubDFmq6AsNtSPFv DjDn/Mc4HhxY6MTtNgmVUb5SAJg/56s31AFYDb/mo9zYZl8XWDTeIdhe78UQl+HQW/mZ bP9w== X-Gm-Message-State: ANhLgQ0NPlJ5uTWlLfjxZdstZwTsRBloV45EO+aEEdlNNuV/9DJBeb05 Z1nFTm3FMR1DlBEBNnQ8BwvqIRKm X-Google-Smtp-Source: ADFU+vtc1cS6fjf+oq+XYLeJ65djUeV/fafzufHJzceYxcQpI4XDQnoXW4ZmosEKyTS1PAKjfidAQA== X-Received: by 2002:aa7:d757:: with SMTP id a23mr16883338eds.26.1584169897018; Sat, 14 Mar 2020 00:11:37 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a7sm4138657ejr.30.2020.03.14.00.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:36 -0700 (PDT) Message-Id: <02afa9c13c1cd299d67003e6984da0b38a53790b.1584169893.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:29 +0000 Subject: [PATCH 3/7] unpack-trees: allow check_updates() to work on a different index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren check_updates() previously assumed it was working on o->result. We want to use this function in combination with a different index_state, so take the intended index_state as a parameter. Signed-off-by: Elijah Newren --- unpack-trees.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unpack-trees.c b/unpack-trees.c index 0d0eec0221e..853d843b17a 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -357,12 +357,12 @@ static void report_collided_checkout(struct index_state *index) string_list_clear(&list, 0); } -static int check_updates(struct unpack_trees_options *o) +static int check_updates(struct unpack_trees_options *o, + struct index_state *index) { unsigned cnt = 0; int errs = 0; struct progress *progress; - struct index_state *index = &o->result; struct checkout state = CHECKOUT_INIT; int i; @@ -1667,7 +1667,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options } } - ret = check_updates(o) ? (-2) : 0; + ret = check_updates(o, &o->result) ? (-2) : 0; if (o->dst_index) { move_index_extensions(&o->result, o->src_index); if (!ret) { From patchwork Sat Mar 14 07:11:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E814392C for ; Sun, 15 Mar 2020 03:41:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C839F20724 for ; Sun, 15 Mar 2020 03:41:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sK0W1cR5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbgCODl0 (ORCPT ); Sat, 14 Mar 2020 23:41:26 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40727 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbgCODlZ (ORCPT ); Sat, 14 Mar 2020 23:41:25 -0400 Received: by mail-ed1-f67.google.com with SMTP id a24so17504627edy.7 for ; Sat, 14 Mar 2020 20:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=A8XZJJ0UxcYV96T6qX+qM+oDEtBWl8LcCAyvkjme6kM=; b=sK0W1cR54xbYOW3dG3VueZksicdAKdkea6l7fQ7xkAL1g2Y57eZin2V+OVW/03RoTW 5VAI35hv93SFcem3YZrCaiunTpJj/uqEhCLOVPdzUAOscLMCWI+HfEEB8+aXQDWiG1Li XVzzblrRnlJKCplAeNxq7LtFsB/OB6o3zujGmGm7tQFggGISnPux/naHN23QW+rAU37R zG4+KoR577FHwc5lrq/42OM9QLM0N7COpAPVsI3aPK9JjdIxgnUe5TFfxbqui0laZyRl xIjOAikRFurM77lhrJuOO3R+nmN8A+lmO+xBJ6/aBTK40JyYokKrb+O6YmRruODx/gkc n1qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=A8XZJJ0UxcYV96T6qX+qM+oDEtBWl8LcCAyvkjme6kM=; b=KX6BA3PlO6uVDuEKGzQEnMtPF2XnVJoUrMxFv+ix0jZVR/PAiyl2suT7KCFnnVdAnE RmwpkddtSnp0aAZOzEuCV8vtcIXTduQatVIkVJ6h6Q57qJvg+zoFetp15fgHbtR09m5B 5jSfgoNWaFrjaIWDVEAI9emwaiKZdmRO2tl9oAhFm90feQ32x4c+7DC4hKpgc1r5wT+V ccKFPd3MV58SPAtcFkwTgUg9SVfsjpRGX2m4I2ljk9J/kDDTSZzs409oTnQlmTCm03+N 5e5osOrGmdhxrtPkmd/g/1vBpXja62lm0o21G5820B5Zkvk/j13t/14ZrA4Ii7G4ziL0 AeDg== X-Gm-Message-State: ANhLgQ2KCId3z1mH9mzwX+xeY1xMCx2+vyDC4QN8wxxSZRZOzcDaV85F drSL6NUShQSsO0Oln22d2qRP150/ X-Google-Smtp-Source: ADFU+vvKDpN0v1yfDAE15XCVxy1tMD3cd4ufPWfoCUJmweKpz1I9EvVHFxYHKViMIpZLAHrbjnr78A== X-Received: by 2002:a17:906:4917:: with SMTP id b23mr15377558ejq.207.1584169897727; Sat, 14 Mar 2020 00:11:37 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id qw14sm841602ejb.14.2020.03.14.00.11.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:37 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:30 +0000 Subject: [PATCH 4/7] unpack-trees: do not mark a dirty path with SKIP_WORKTREE Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren If a path is dirty, removing from the working tree risks losing data. As such, we want to make sure any such path is not marked with SKIP_WORKTREE. While the current callers of this code detect this case and re-populate with a previous set of sparsity patterns, we want to allow some paths to be marked with SKIP_WORKTREE while others are left unmarked without it being considered an error. The reason this shouldn't be considered an error is that SKIP_WORKTREE has always been an advisory-only setting; merge and rebase for example were free to materialize paths and clear the SKIP_WORKTREE bit in order to accomplish their work even though they kept the SKIP_WORKTREE bit set for other paths. Leaving dirty working files in the working tree is thus a natural extension of what we have already been doing. Signed-off-by: Elijah Newren --- unpack-trees.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unpack-trees.c b/unpack-trees.c index 853d843b17a..8f10ac91ce1 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -504,8 +504,11 @@ static int apply_sparse_checkout(struct index_state *istate, * also stat info may have lost after merged_entry() so calling * verify_uptodate() again may fail */ - if (!(ce->ce_flags & CE_UPDATE) && verify_uptodate_sparse(ce, o)) + if (!(ce->ce_flags & CE_UPDATE) && + verify_uptodate_sparse(ce, o)) { + ce->ce_flags &= ~CE_SKIP_WORKTREE; return -1; + } ce->ce_flags |= CE_WT_REMOVE; ce->ce_flags &= ~CE_UPDATE; } From patchwork Sat Mar 14 07:11:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E807E92C for ; Sun, 15 Mar 2020 03:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B710820716 for ; Sun, 15 Mar 2020 03:46:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hSldAmex" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727414AbgCODqN (ORCPT ); Sat, 14 Mar 2020 23:46:13 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:33595 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbgCODqN (ORCPT ); Sat, 14 Mar 2020 23:46:13 -0400 Received: by mail-ed1-f68.google.com with SMTP id z65so17545437ede.0 for ; Sat, 14 Mar 2020 20:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=yGyt7AQ8zTjyW31n3uBMr0ANdqgK0pfoIKf0uKriifI=; b=hSldAmexDa0VFj/pu3sFHSkw0IwBVkWKYIQgzY1RurWqkRoKEUpwFSKYTdjwLbRXal yvwAI3YklPlHmWwIZ8ijHKg7zDtoY+8rzzBW7lkAl/zUO+fOiBfT+s+QnzbTwQFGrVHC faQTcN8SL5KjAU5JRHaGGYh8csTtlGna6v6THb1IQX3uqNje+qzvmYbJDk4/ZtQUe+Kd GaE68nlHXLnmgLUIJEE2+hyl8XNOvQT0tJ15EJwrbOy54AjtU5dbWQSVUX4lwgie7FOH lomqFegnB3IkWSCdDxEB945eRCWUXSFs9JiDjzwAEqOoCEi8NgUefh+dPYJNRgp8wBFp QLEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=yGyt7AQ8zTjyW31n3uBMr0ANdqgK0pfoIKf0uKriifI=; b=DDiCrbswhtpiS84ftyXwJNVC/1lshNczJWXFojTRfMyxoLLGvw0Jifhf72OOB7ASxr zG067ym1NvibrA7Ls3GU3C76O5c0uge7rNcgFBbI6jkPzgOKJkbCht5VhTYv1zz174AK coh1ZuCAtMQRCT51JE7zHXDw2lvdexD1wQuS6j254wG6W+hqDVLbWflgxy6XlHZxloSC 7BKMw7E8qRKqj0h4CyOF1qTjJf4ZFPCeoRnrRWiqjr/oootB0MV7G2Z7ghFq0ZY7p6E7 LEV91GaGspTkxKK6KsVTyGUBC/8yvV7O1ScXf8L/ZKX1ExrbSO/9wa1wE9FXBNVwDYzj 8Z3Q== X-Gm-Message-State: ANhLgQ0ZXcejv8EL4FKput2fFAdFj7iIXKZ9JGGmXPhXiL3MWP9Wwf3o Bm0FSdaJhf+sPGjSaZiNsvms11SS X-Google-Smtp-Source: ADFU+vv2cW6oq4+yoMTTCT9kVYNWOjBd0hH3/pUGaIszeOEICQnIcYbkvwIQyPuJWZEjIU+cMCWcZw== X-Received: by 2002:a05:6402:1d2d:: with SMTP id dh13mr16840028edb.276.1584169898541; Sat, 14 Mar 2020 00:11:38 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t1sm4053338eju.35.2020.03.14.00.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:38 -0700 (PDT) Message-Id: <9f13a2e8c64d47a5b3a4a2a96451decaf548ca4e.1584169893.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:31 +0000 Subject: [PATCH 5/7] unpack-trees: add a new update_sparsity() function Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Previously, the only way to update the SKIP_WORKTREE bits for various paths was invoking `git read-tree -mu HEAD` or calling the same code that this codepath invoked. This however had a number of problems. Let's look at all the various cases: Flipping SKIP_WORKTREE -> !SKIP_WORKTREE (materializing files): A) There is no file in the way B) There is an untracked file in the way Flipping !SKIP_WORKTREE -> SKIP_WORKTREE (removing files): C) The path is clean D) The path is unmerged E) The path has unstaged changes F) The path has staged changes (differs from HEAD) For `git read-tree -mu HEAD`, the behavior is as follows: A) Materialize the file, as expected B) Refuse to make *any* changes (to this path or any others) C) Remove the file, as expected D) Refuse to make *any* changes (to this path or any others) E) Refuse to make *any* changes (to this path or any others) F) Removes the file from the working copy AND resets the index to match HEAD Refusing to modify files that could result in data loss as in cases B, D, and E is good, but refusing to work on any other paths is very problematic for users. If they are in the middle of a rebase or have made modifications to files that bring in more dependencies, then for their build to work they need to update the sparse paths -- which they are prevented from doing. Sometimes they stage the files and re-try, at which point they run into case F and believe that their changes are lost. (Even if they come ask an expert, they have to trawl through their loose objects looking for which ones match which files.) Add a new update_sparsity() function which behaves as follows in these cases: A) Materialize the file, as expected B) Leave the file in the working copy alone, clear the SKIP_WORKTREE bit, and print a warning (thus leaving them in a state where status will report the file as modified, which seems logical). C) Remove the file, as expected D) Do NOT mark this path as SKIP_WORKTREE, but allow others paths to be updated. E) Do NOT mark this path as SKIP_WORKTREE and print a warning about the dirty path, but allow other paths to be updated. F) Mark the path as SKIP_WORKTREE, but do not revert the version stored in the index to match HEAD; leave the contents alone. I tried a different behavior for B (leave the SKIP_WORKTREE bit set), but found it very surprising and counter-intuitive (e.g. the user sees it is present along with all the other files in that directory, tries to stage it, but git add ignores it since the SKIP_WORKTREE bit is set). A, B, C, and E all seem like optimal behavior to me. D may be as well, though I wonder if printing a warning would be an improvement. Some might be slightly surprised by F at first, but given that it does the right thing with `git commit` and even `git commit -a` (add ignores entries that are marked SKIP_WORKTREE and thus doesn't delete them, and commit -a is similar), it seems logical to me. Signed-off-by: Elijah Newren --- unpack-trees.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++ unpack-trees.h | 2 + 2 files changed, 108 insertions(+) diff --git a/unpack-trees.c b/unpack-trees.c index 8f10ac91ce1..21234635573 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -255,6 +255,25 @@ static void display_error_msgs(struct unpack_trees_options *o) fprintf(stderr, _("Aborting\n")); } +/* + * display all the "error" messages as warnings + */ +static void display_warning_msgs(struct unpack_trees_options *o) +{ + int e, i; + for (e = 0; e < NB_UNPACK_TREES_ERROR_TYPES; e++) { + struct string_list *rejects = &o->unpack_rejects[e]; + if (rejects->nr > 0) { + struct strbuf path = STRBUF_INIT; + for (i = 0; i < rejects->nr; i++) + strbuf_addstr(&path, rejects->items[i].string); + warning(ERRORMSG(o, e), super_prefixed(path.buf)); + strbuf_release(&path); + } + string_list_clear(rejects, 0); + } +} + static int check_submodule_move_head(const struct cache_entry *ce, const char *old_id, const char *new_id, @@ -1708,6 +1727,93 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options goto done; } +/* + * Update SKIP_WORKTREE bits according to sparsity patterns, and update + * working directory to match. + * + * Returns + * 0: success with no warnings + * 1: success with warnings (warnings come either from (a) dirty changes + * present in which case we avoid marking those paths as + * SKIP_WORKTREE, or (b) from untracked files being in the way us + * checking a file out of the index, in which case we leave the file + * in the working tree alone while clearing SKIP_WORKTREE) + * -1: failure to manipulate the resulting index + * -2: failure to reflect the changes to the work tree. + * + * CE_NEW_SKIP_WORKTREE is used internally. + */ +int update_sparsity(struct unpack_trees_options *o) +{ + struct pattern_list pl; + int i, empty_worktree, ret = 0; + unsigned old_show_all_errors; + + old_show_all_errors = o->show_all_errors; + o->show_all_errors = 1; + + /* Sanity checks */ + if (!o->update || o->index_only || o->skip_sparse_checkout) + BUG("update_sparsity() is for reflecting sparsity patterns in working directory"); + if (o->src_index != o->dst_index || o->fn) + BUG("update_sparsity() called wrong"); + + trace_performance_enter(); + + if (!o->pl) { + char *sparse = git_pathdup("info/sparse-checkout"); + memset(&pl, 0, sizeof(pl)); + pl.use_cone_patterns = core_sparse_checkout_cone; + if (add_patterns_from_file_to_list(sparse, "", 0, &pl, NULL) < 0) { + /* FIXME: Skip to check_updates()?? */ + o->skip_sparse_checkout = 1; + goto skip_sparse_checkout; + } else + o->pl = &pl; + free(sparse); + } + + /* Set NEW_SKIP_WORKTREE on existing entries. */ + mark_all_ce_unused(o->src_index); + mark_new_skip_worktree(o->pl, o->src_index, 0, + CE_NEW_SKIP_WORKTREE, o->verbose_update); + + /* Then loop over entries and update/remove as needed */ + ret = 0; + empty_worktree = 1; + for (i = 0; i < o->src_index->cache_nr; i++) { + struct cache_entry *ce = o->src_index->cache[i]; + + if (apply_sparse_checkout(o->src_index, ce, o)) + ret = 1; + + if (!ce_skip_worktree(ce)) + empty_worktree = 0; + + } + + /* + * Sparse checkout is meant to narrow down checkout area + * but it does not make sense to narrow down to empty working + * tree. This is usually a mistake in sparse checkout rules. + * Do not allow users to do that. + */ + if (o->src_index->cache_nr && empty_worktree) { + ret = unpack_failed(o, "Sparse checkout leaves no entry on working directory"); + goto done; + } + +skip_sparse_checkout: + if (check_updates(o, o->src_index)) + ret = -2; + +done: + display_warning_msgs(o); + o->show_all_errors = old_show_all_errors; + trace_performance_leave("update_sparsity"); + return ret; +} + /* Here come the merge functions */ static int reject_merge(const struct cache_entry *ce, diff --git a/unpack-trees.h b/unpack-trees.h index ae1557fb804..5d1a77ae249 100644 --- a/unpack-trees.h +++ b/unpack-trees.h @@ -90,6 +90,8 @@ struct unpack_trees_options { int unpack_trees(unsigned n, struct tree_desc *t, struct unpack_trees_options *options); +int update_sparsity(struct unpack_trees_options *options); + int verify_uptodate(const struct cache_entry *ce, struct unpack_trees_options *o); From patchwork Sat Mar 14 07:11:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EA251667 for ; Sun, 15 Mar 2020 04:55:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 547C820575 for ; Sun, 15 Mar 2020 04:55:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qG/YfbKu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726345AbgCOEzi (ORCPT ); Sun, 15 Mar 2020 00:55:38 -0400 Received: from mail-lj1-f176.google.com ([209.85.208.176]:34500 "EHLO mail-lj1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726136AbgCOEzi (ORCPT ); Sun, 15 Mar 2020 00:55:38 -0400 Received: by mail-lj1-f176.google.com with SMTP id s13so14933090ljm.1 for ; Sat, 14 Mar 2020 21:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ftQDiJizTOtP0QcekVoFF73SnUn8cFs+C+BqLKuJbls=; b=qG/YfbKuayrcd7xBhGxUlPH5brgVPg6I9034gdHRAZYlugVSyT9XqdgAKoHPTGnIPE EUWfHE0rfnnTpaWlo0QueDhZ+r9QR/lYko6QjItUnZnCdwE9D7gWixcIEibSUCACmybe nslvCjmvJQs7qbVNGkks7m/QimrBJkh1ca4JVjo1QHcSU6IXCh6hIAwleF1kvdBSsJ8U PF/kBlwIsNdRfGda7POhtCmG5l7SC8Dz7/JTganb2Ei3CLsJYXlDC0uN5BP7/jcJUEef 043pQfSRZkVW59qSe7uHoelxT6jxtCY7pSdKfmFxOnm79r1obJyU7xIY+Qhz/bYnotok Im7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ftQDiJizTOtP0QcekVoFF73SnUn8cFs+C+BqLKuJbls=; b=b4OPOtp6xayqlQFVJkFIPLkSRomC8a8A/hbyI7Ly5Ivtay2bedckKsMi7tceqx6SZk 4H6/qLaBOwFugINXXO6/3Z46O7ZDBw+tSPaxNoeY/+jMl8bwNCEPSZ90h/9HIvUkDA16 THTkkTfKikbREobp0qoHgJrjxTbATQ/VJGxZAO5JwDwrZKJZr10qWu7lNGYfZffbIJYK VQrTgbtTuC0QoiGmfiM0HgAWL/1i+qJd4mr4ryUMFclOiDxQVLchyuIOTOFQscfV0SjO +H3szEpkafP3UNSzJcWlnh8qjXe4hXDcpJMlshY+sDvwehFVLwUlVtjL5hxWeYWdsyFN Iryw== X-Gm-Message-State: ANhLgQ03QoXhObWOSphBJL/VUQK/nrJieuKnMjHfuZPIYGnRYEuo9qm6 I4xaU0fBID6UirPENk5ecGX45XeL X-Google-Smtp-Source: ADFU+vtnpDdVeP9Eyw4dVH7ZUIg/Dpy+3oaKdXKxNlFbtj6feEq7fQhwCUf4Eubrq33G/f53ppbR4g== X-Received: by 2002:aa7:dc4f:: with SMTP id g15mr9870670edu.244.1584169899189; Sat, 14 Mar 2020 00:11:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id qw14sm841604ejb.14.2020.03.14.00.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:38 -0700 (PDT) Message-Id: <892933752c638a9ed938e046e466dd1e927058a6.1584169893.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:32 +0000 Subject: [PATCH 6/7] sparse-checkout: use new update_sparsity() function Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Remove the equivalent of 'git read-tree -mu HEAD' in the sparse-checkout codepaths for setting the SKIP_WORKTREE bits and instead use the new update_sparsity() function. Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 39 +++++++----------------------- t/t1091-sparse-checkout-builtin.sh | 32 +++++++++++++++++------- 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 740da4b6d54..5d3ec2e6be9 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -97,47 +97,32 @@ static int update_working_directory(struct pattern_list *pl) int result = 0; struct unpack_trees_options o; struct lock_file lock_file = LOCK_INIT; - struct object_id oid; - struct tree *tree; - struct tree_desc t; struct repository *r = the_repository; - if (repo_read_index_unmerged(r)) - die(_("you need to resolve your current index first")); - - if (get_oid("HEAD", &oid)) - return 0; - - tree = parse_tree_indirect(&oid); - parse_tree(tree); - init_tree_desc(&t, tree->buffer, tree->size); - memset(&o, 0, sizeof(o)); o.verbose_update = isatty(2); - o.merge = 1; o.update = 1; - o.fn = oneway_merge; o.head_idx = -1; o.src_index = r->index; o.dst_index = r->index; o.skip_sparse_checkout = 0; o.pl = pl; - o.keep_pattern_list = !!pl; - resolve_undo_clear_index(r->index); setup_work_tree(); - cache_tree_free(&r->index->cache_tree); - repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR); - core_apply_sparse_checkout = 1; - result = unpack_trees(1, &t, &o); + result = update_sparsity(&o); - if (!result) { - prime_cache_tree(r, r->index, tree); + if (result == 1) + /* + * We don't do any special handling of warnings from untracked + * files in the way or dirty entries that can't be removed. + */ + result = 0; + if (!result) write_locked_index(r->index, &lock_file, COMMIT_LOCK); - } else + else rollback_lock_file(&lock_file); return result; @@ -304,8 +289,6 @@ static int sparse_checkout_init(int argc, const char **argv) }; repo_read_index(the_repository); - require_clean_work_tree(the_repository, - N_("initialize sparse-checkout"), NULL, 1, 0); argc = parse_options(argc, argv, NULL, builtin_sparse_checkout_init_options, @@ -560,8 +543,6 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix, }; repo_read_index(the_repository); - require_clean_work_tree(the_repository, - N_("set sparse-checkout patterns"), NULL, 1, 0); argc = parse_options(argc, argv, prefix, builtin_sparse_checkout_set_options, @@ -577,8 +558,6 @@ static int sparse_checkout_disable(int argc, const char **argv) struct strbuf match_all = STRBUF_INIT; repo_read_index(the_repository); - require_clean_work_tree(the_repository, - N_("disable sparse-checkout"), NULL, 1, 0); memset(&pl, 0, sizeof(pl)); hashmap_init(&pl.recursive_hashmap, pl_hashmap_cmp, NULL, 0); diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index 8607a8e6d1a..0d93d3983e0 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -277,16 +277,23 @@ test_expect_success 'cone mode: add parent path' ' check_files repo a deep folder1 ' -test_expect_success 'revert to old sparse-checkout on bad update' ' +test_expect_success 'not-up-to-date does not block rest of sparsification' ' test_when_finished git -C repo sparse-checkout disable && test_when_finished git -C repo reset --hard && git -C repo sparse-checkout set deep && + echo update >repo/deep/deeper2/a && cp repo/.git/info/sparse-checkout expect && - test_must_fail git -C repo sparse-checkout set deep/deeper1 2>err && - test_i18ngrep "cannot set sparse-checkout patterns" err && - test_cmp repo/.git/info/sparse-checkout expect && - check_files repo/deep a deeper1 deeper2 + test_write_lines "!/deep/*/" "/deep/deeper1/" >>expect && + + git -C repo sparse-checkout set deep/deeper1 2>err && + + test_i18ngrep "Cannot update sparse checkout" err && + test_cmp expect repo/.git/info/sparse-checkout && + check_files repo/deep a deeper1 deeper2 && + check_files repo/deep/deeper1 a deepest && + check_files repo/deep/deeper1/deepest a && + check_files repo/deep/deeper2 a ' test_expect_success 'revert to old sparse-checkout on empty update' ' @@ -316,12 +323,19 @@ test_expect_success '.gitignore should not warn about cone mode' ' test_i18ngrep ! "disabling cone patterns" err ' -test_expect_success 'sparse-checkout (init|set|disable) fails with dirty status' ' +test_expect_success 'sparse-checkout (init|set|disable) warns with dirty status' ' git clone repo dirty && echo dirty >dirty/folder1/a && - test_must_fail git -C dirty sparse-checkout init && - test_must_fail git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* && - test_must_fail git -C dirty sparse-checkout disable && + + git -C dirty sparse-checkout init 2>err && + test_i18ngrep "warning.*Cannot update sparse checkout" err && + + git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* && + test_i18ngrep "warning.*Cannot update sparse checkout" err && + + git -C dirty sparse-checkout disable && + test_i18ngrep "warning.*Cannot update sparse checkout" err && + git -C dirty reset --hard && git -C dirty sparse-checkout init && git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* && From patchwork Sat Mar 14 07:11:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11438549 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62B221392 for ; Sun, 15 Mar 2020 01:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41BA02076A for ; Sun, 15 Mar 2020 01:57:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VR2XAv65" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727312AbgCOB5P (ORCPT ); Sat, 14 Mar 2020 21:57:15 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35189 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726853AbgCOB5P (ORCPT ); Sat, 14 Mar 2020 21:57:15 -0400 Received: by mail-ed1-f65.google.com with SMTP id a20so17383420edj.2 for ; Sat, 14 Mar 2020 18:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=7vURZjwLWnQZCWJk6JJhvnUshrHeJ75H/tj5ds8LnMU=; b=VR2XAv65byNhTJzPvrZy2pd5fNuxz9LUB7YNoE2QSRUDMM73D3SRlAtJv0JtrmyjsN 7LFuh09sPaS1EgIus7h3SBoE7wME6XbdvTN1RGle4URR05KouP0N9rrSdxS0xDseKsxl lOnhSG9TmdYrVc3KebZ5Ysp6udRUSqhThaF+wNguWzI29ZeoulHkW+NlZVqUcmDCE0Ck j7B9ktpJ/F1HqS5qwiz4ZfsOBdvChmIoKlH7KJBtJGlSTMT+z/14XMVGWQCXpAlHK2j1 j6h6KLxoIS1AVuGr7CgdPXcmfzDk+crXomVZWzDaD7mwwpvnBEHU93WsYiY22fqxK0cU 1hyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=7vURZjwLWnQZCWJk6JJhvnUshrHeJ75H/tj5ds8LnMU=; b=t8qkxaEWL8O+qAfbqLA9y0sleoPKyrTQYxO7AwsfBVC+M8XQ5fVywMrTIAaQfAKDLU E5BPJ0P+ztJEG5XtfBTfESOjPFNsZXQavhTdKtWAcEZYldFhYKMTGRz+b5iSJUHS+TXS a9wan01LGHZpwK63fP0eETGV3Td2qF4X85GlivpIDzKncpYzhialBAJSeFrZ4r+WjiHT DSPL+6AaK7p6YO66SscS/VbVmkEvAWh/moyU+9THHltdBSMSI8AVVuk261uSVhxZNVAd XqQ7pLQZz+egIjdb5o2fBT71cGe5SDdxK5dvsaf9g0zKEWFE6fYO0TbvYjdwJrswFcVQ R5Zg== X-Gm-Message-State: ANhLgQ03U20Si7VDMkFS5bc4IqLa5wKmkST9YB75KPkmOtidUFk8TD13 FT2z2lmNqMzmu06TVQQg7CFUUAFG X-Google-Smtp-Source: ADFU+vvy/KWa7oPVHaFt50kQ9CZQJE1H7Hd/WupMvRUf7ZtwVluOvwgMZlIIfGULtoi9dFqzyUrfWQ== X-Received: by 2002:a50:b905:: with SMTP id m5mr16951332ede.154.1584169899852; Sat, 14 Mar 2020 00:11:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u26sm4283787ejb.34.2020.03.14.00.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 00:11:39 -0700 (PDT) Message-Id: <650db6863426ae2b324ba717f898247f44279cb8.1584169893.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Sat, 14 Mar 2020 07:11:33 +0000 Subject: [PATCH 7/7] sparse-checkout: provide a new update subcommand Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren If commands like merge or rebase materialize files as part of their work, or a previous sparse-checkout command failed to update individual files due to dirty changes, users may want a command to simply 'reapply' the sparsity rules. Provide one. Signed-off-by: Elijah Newren --- Documentation/git-sparse-checkout.txt | 10 ++++++++++ builtin/sparse-checkout.c | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/git-sparse-checkout.txt b/Documentation/git-sparse-checkout.txt index c0342e53938..27f4392489f 100644 --- a/Documentation/git-sparse-checkout.txt +++ b/Documentation/git-sparse-checkout.txt @@ -70,6 +70,16 @@ C-style quoted strings. `core.sparseCheckoutCone` is enabled, the given patterns are interpreted as directory names as in the 'set' subcommand. +'update':: + Update the sparseness of paths in the working tree based on the + existing patterns. Commands like merge or rebase can materialize + paths to do their work (e.g. in order to show you a conflict), and + other sparse-checkout commands might fail to sparsify an individual + file (e.g. because it has unstaged changes or conflicts). In such + cases, it can make sense to run `git sparse-checkout update` later + after cleaning up affected paths (e.g. resolving conflicts, undoing + or committing changes, etc.). + 'disable':: Disable the `core.sparseCheckout` config setting, and restore the working directory to include all files. Leaves the sparse-checkout diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 5d3ec2e6be9..2ae21011dfd 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -18,7 +18,7 @@ static const char *empty_base = ""; static char const * const builtin_sparse_checkout_usage[] = { - N_("git sparse-checkout (init|list|set|add|disable) "), + N_("git sparse-checkout (init|list|set|add|update|disable) "), NULL }; @@ -552,6 +552,12 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix, return modify_pattern_list(argc, argv, m); } +static int sparse_checkout_update(int argc, const char **argv) +{ + repo_read_index(the_repository); + return update_working_directory(NULL); +} + static int sparse_checkout_disable(int argc, const char **argv) { struct pattern_list pl; @@ -601,6 +607,8 @@ int cmd_sparse_checkout(int argc, const char **argv, const char *prefix) return sparse_checkout_set(argc, argv, prefix, REPLACE); if (!strcmp(argv[0], "add")) return sparse_checkout_set(argc, argv, prefix, ADD); + if (!strcmp(argv[0], "update")) + return sparse_checkout_update(argc, argv); if (!strcmp(argv[0], "disable")) return sparse_checkout_disable(argc, argv); }