From patchwork Tue Dec 14 04:09:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9212C433EF for ; Tue, 14 Dec 2021 04:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233638AbhLNEJQ (ORCPT ); Mon, 13 Dec 2021 23:09:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232880AbhLNEJP (ORCPT ); Mon, 13 Dec 2021 23:09:15 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E6D8C06173F for ; Mon, 13 Dec 2021 20:09:15 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id k9so12504112wrd.2 for ; Mon, 13 Dec 2021 20:09:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=5O7bMp84Jyts8epnhDhcyGVe2LpRReexaYYndBHitCk=; b=EiYNNNYoMRs6bAs3Z3+q7In6VQf0nwAm/nxMUEuTy7IHrL9Ir1lpjGQIxSvUA7xHaZ AbVTvp9bbC6latiUEKDcDqKSNNiYkeN0JfYnJUWOQ3oj9/dfZHc9H4t/jWhY4kE/5D9V GB+JLbZAGi+BAgWGTWouj+86Rf1PBylIUZHLK0uF+++Q9Somv1nN6WVRu6DErA29jqod l/2b65+UtpfciJXm0DrOKN5drALRqdPNnzZUPZPSBWOGVGnc0svBqY9VVWs8T+oCF9ec tQBxwsjhiGYRpY7013vikxQJhzMQiNvU+1UXW6TvDbZP0BMfRY/q6OvhSEAtosEyTsqQ BCcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=5O7bMp84Jyts8epnhDhcyGVe2LpRReexaYYndBHitCk=; b=d2RONYb/2NQsv2CYLgDsMMAZsvJQ/0X0mSJzTUHRp9s0dWSxrfePxvDC5LO/3TrCFN y6kmeRva7pnjmGM+qppNXq3fPkAX9s3csNe+Z+P+u4wPhog7bzAlPs6yZSRsnmsbAH74 DyxTWlSEyh7q4c0WdDzO91Q9OUiQD47xzn7zAshWVPykUP6SuSPSb/SWPG1v04jgqNzq 5QfldK8BGDNIqjKarLTsXeQpe/5+lXUvB4titfXajGTsFP0WEBuikv62F1ZCpe7eSfcW 96nTfyZgosXQ1ZFhJZU/lIDsGCa06vkpCIBlvvo5DyUn2wAGP0M2E1vhtIW7W/sDhzb+ dtyQ== X-Gm-Message-State: AOAM531ktZJS60pDGCbpcj18u/0Z1c0C5aeahtopTARWhuC/rHk5X5z4 dnJZWgpM94vD680XlMj8HbblgrCpozA= X-Google-Smtp-Source: ABdhPJw4imstSEqPC5KVhj/h/b9meaK1dvdVSb+Lx/DAPtZgx3q4UViuUj+OyuxAib3b9E6vMfS5Ow== X-Received: by 2002:a05:6000:1a43:: with SMTP id t3mr3069589wry.555.1639454953790; Mon, 13 Dec 2021 20:09:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m20sm898074wmq.11.2021.12.13.20.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:13 -0800 (PST) Message-Id: <814aed2d125b4d5e41b70e731f1475a22bde64db.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:03 +0000 Subject: [PATCH v4 01/10] sparse-checkout: pass use_stdin as a parameter instead of as a global Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren add_patterns_from_input() has relied on a global variable, set_opts.use_stdin, which has been used by both the `set` and `add` subcommands of sparse-checkout. Once we introduce an add_opts.use_stdin, the hardcoding of set_opts.use_stdin will be incorrect. Pass the value as function parameter instead to allow us to make subsequent changes. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index d0f5c4702be..8612328e5dd 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -525,7 +525,8 @@ static struct sparse_checkout_set_opts { } set_opts; static void add_patterns_from_input(struct pattern_list *pl, - int argc, const char **argv) + int argc, const char **argv, + int use_stdin) { int i; if (core_sparse_checkout_cone) { @@ -535,7 +536,7 @@ static void add_patterns_from_input(struct pattern_list *pl, hashmap_init(&pl->parent_hashmap, pl_hashmap_cmp, NULL, 0); pl->use_cone_patterns = 1; - if (set_opts.use_stdin) { + if (use_stdin) { struct strbuf unquoted = STRBUF_INIT; while (!strbuf_getline(&line, stdin)) { if (line.buf[0] == '"') { @@ -559,7 +560,7 @@ static void add_patterns_from_input(struct pattern_list *pl, } } } else { - if (set_opts.use_stdin) { + if (use_stdin) { struct strbuf line = STRBUF_INIT; while (!strbuf_getline(&line, stdin)) { @@ -580,7 +581,8 @@ enum modify_type { }; static void add_patterns_cone_mode(int argc, const char **argv, - struct pattern_list *pl) + struct pattern_list *pl, + int use_stdin) { struct strbuf buffer = STRBUF_INIT; struct pattern_entry *pe; @@ -588,7 +590,7 @@ static void add_patterns_cone_mode(int argc, const char **argv, struct pattern_list existing; char *sparse_filename = get_sparse_checkout_filename(); - add_patterns_from_input(pl, argc, argv); + add_patterns_from_input(pl, argc, argv, use_stdin); memset(&existing, 0, sizeof(existing)); existing.use_cone_patterns = core_sparse_checkout_cone; @@ -614,17 +616,19 @@ static void add_patterns_cone_mode(int argc, const char **argv, } static void add_patterns_literal(int argc, const char **argv, - struct pattern_list *pl) + struct pattern_list *pl, + int use_stdin) { char *sparse_filename = get_sparse_checkout_filename(); if (add_patterns_from_file_to_list(sparse_filename, "", 0, pl, NULL, 0)) die(_("unable to load existing sparse-checkout patterns")); free(sparse_filename); - add_patterns_from_input(pl, argc, argv); + add_patterns_from_input(pl, argc, argv, use_stdin); } -static int modify_pattern_list(int argc, const char **argv, enum modify_type m) +static int modify_pattern_list(int argc, const char **argv, int use_stdin, + enum modify_type m) { int result; int changed_config = 0; @@ -633,13 +637,13 @@ static int modify_pattern_list(int argc, const char **argv, enum modify_type m) switch (m) { case ADD: if (core_sparse_checkout_cone) - add_patterns_cone_mode(argc, argv, pl); + add_patterns_cone_mode(argc, argv, pl, use_stdin); else - add_patterns_literal(argc, argv, pl); + add_patterns_literal(argc, argv, pl, use_stdin); break; case REPLACE: - add_patterns_from_input(pl, argc, argv); + add_patterns_from_input(pl, argc, argv, use_stdin); break; } @@ -675,7 +679,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix, builtin_sparse_checkout_set_usage, PARSE_OPT_KEEP_UNKNOWN); - return modify_pattern_list(argc, argv, m); + return modify_pattern_list(argc, argv, set_opts.use_stdin, m); } static char const * const builtin_sparse_checkout_reapply_usage[] = { From patchwork Tue Dec 14 04:09:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B340FC433EF for ; Tue, 14 Dec 2021 04:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233858AbhLNEJT (ORCPT ); Mon, 13 Dec 2021 23:09:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbhLNEJQ (ORCPT ); Mon, 13 Dec 2021 23:09:16 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE829C061574 for ; Mon, 13 Dec 2021 20:09:15 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 133so13395328wme.0 for ; Mon, 13 Dec 2021 20:09:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=mAOerwPUMrfnXbLVjrNgMJnuirc3MJ3a20wdnsiRbIw=; b=WVxOhP6S4d86OQf2ambdGjJDDJHm62neY5xuSWL+rlrwAyMOZn/lwI/gXzGJzVwoq7 AwajCWDisrdQBw4bQ/s8gpoMTg/lY5+RVfZ8N/CcRN7qPWecjjebYS0gLYrBjPG1hljB AJDAEWGEvaOYfxvntzWhiRsmxnb9Sgh7K0gFJA2imdr0ffDVrivg8ifrX+nS5c2kbnsK VHbR+8lirHN0YsnMY8QEJxMlfF8kYp7QFMF+p3imsbexEdIe6qVLvb5xHcT6MPSyGbok SqYEx/sHPUEQBQR4hHsxvB4La2rcujVF0MQokiyYOJcLbW6XkaB3wBgYWNuol+ZGCkji fEjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=mAOerwPUMrfnXbLVjrNgMJnuirc3MJ3a20wdnsiRbIw=; b=bpHElFyTnwuv3tY9OHhb+aDcFAn7lpww7XHTM02UkKuH61Lg06RSVT+KX59ATkRgeV QlEvo/nXee89V9cSt/dAb6v+fEFWbHrHu6y6Hcl/4ZKs6TS7eFIj9Ih0mrQy+rIuypJf gtv9DwAtenhZ5EC90mtC9YP2wkQXkcUP3d08L3fJAIcSp9XLJJvU63UNGQZtJoA0Q+dc A8VgAmBsVIoTwku7sxqBU/hj9WbzFGk/yOgd8FGhRjXZ/GqemK5ZOh1vvyIZnZJe9YzD eaZFvG9g/nWdMqzqOIB4TYb2OnPNtCRvkKjVQdK963PsNCsI7FEDNhaCvnrARLuSFaSD SSPA== X-Gm-Message-State: AOAM532XpoGUQVmpIufJDM9/IIoJ6r2rJVSUaZ6RX0kykeay9UcTChkK kTtPmioUWgecXiERSA2Eop7W43L6W/c= X-Google-Smtp-Source: ABdhPJxtQotLMRiul+j37yMnuAOtbE9Ikqs6afV+lP6PSz58IA68ik6410J66izdrL50Rfn+NLkaiA== X-Received: by 2002:a05:600c:154f:: with SMTP id f15mr42902143wmg.86.1639454954389; Mon, 13 Dec 2021 20:09:14 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o1sm11097618wri.100.2021.12.13.20.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:14 -0800 (PST) Message-Id: <04cd57592e9331985db2e827459775ed9bc8a22b.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:04 +0000 Subject: [PATCH v4 02/10] sparse-checkout: break apart functions for sparse_checkout_(set|add) Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren sparse_checkout_set() was reused by sparse_checkout_add() with the only difference being a single parameter being passed to that function. However, we would like sparse_checkout_set() to do the same work that sparse_checkout_init() does if sparse checkouts are not already enabled. To facilitate this transition, give each mode their own copy of the function. This does not introduce any behavioral changes; that will come in a subsequent patch. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 54 +++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 8612328e5dd..e252b82136e 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -515,15 +515,6 @@ static void strbuf_to_cone_pattern(struct strbuf *line, struct pattern_list *pl) insert_recursive_pattern(pl, line); } -static char const * const builtin_sparse_checkout_set_usage[] = { - N_("git sparse-checkout (set|add) (--stdin | )"), - NULL -}; - -static struct sparse_checkout_set_opts { - int use_stdin; -} set_opts; - static void add_patterns_from_input(struct pattern_list *pl, int argc, const char **argv, int use_stdin) @@ -663,8 +654,43 @@ static int modify_pattern_list(int argc, const char **argv, int use_stdin, return result; } -static int sparse_checkout_set(int argc, const char **argv, const char *prefix, - enum modify_type m) +static char const * const builtin_sparse_checkout_add_usage[] = { + N_("git sparse-checkout add (--stdin | )"), + NULL +}; + +static struct sparse_checkout_add_opts { + int use_stdin; +} add_opts; + +static int sparse_checkout_add(int argc, const char **argv, const char *prefix) +{ + static struct option builtin_sparse_checkout_add_options[] = { + OPT_BOOL(0, "stdin", &add_opts.use_stdin, + N_("read patterns from standard in")), + OPT_END(), + }; + + repo_read_index(the_repository); + + argc = parse_options(argc, argv, prefix, + builtin_sparse_checkout_add_options, + builtin_sparse_checkout_add_usage, + PARSE_OPT_KEEP_UNKNOWN); + + return modify_pattern_list(argc, argv, add_opts.use_stdin, ADD); +} + +static char const * const builtin_sparse_checkout_set_usage[] = { + N_("git sparse-checkout set (--stdin | )"), + NULL +}; + +static struct sparse_checkout_set_opts { + int use_stdin; +} set_opts; + +static int sparse_checkout_set(int argc, const char **argv, const char *prefix) { static struct option builtin_sparse_checkout_set_options[] = { OPT_BOOL(0, "stdin", &set_opts.use_stdin, @@ -679,7 +705,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix, builtin_sparse_checkout_set_usage, PARSE_OPT_KEEP_UNKNOWN); - return modify_pattern_list(argc, argv, set_opts.use_stdin, m); + return modify_pattern_list(argc, argv, set_opts.use_stdin, REPLACE); } static char const * const builtin_sparse_checkout_reapply_usage[] = { @@ -762,9 +788,9 @@ int cmd_sparse_checkout(int argc, const char **argv, const char *prefix) if (!strcmp(argv[0], "init")) return sparse_checkout_init(argc, argv); if (!strcmp(argv[0], "set")) - return sparse_checkout_set(argc, argv, prefix, REPLACE); + return sparse_checkout_set(argc, argv, prefix); if (!strcmp(argv[0], "add")) - return sparse_checkout_set(argc, argv, prefix, ADD); + return sparse_checkout_add(argc, argv, prefix); if (!strcmp(argv[0], "reapply")) return sparse_checkout_reapply(argc, argv); if (!strcmp(argv[0], "disable")) From patchwork Tue Dec 14 04:09:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00ADEC433FE for ; Tue, 14 Dec 2021 04:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233924AbhLNEJV (ORCPT ); Mon, 13 Dec 2021 23:09:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233692AbhLNEJR (ORCPT ); Mon, 13 Dec 2021 23:09:17 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87930C061574 for ; Mon, 13 Dec 2021 20:09:16 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id a9so30278993wrr.8 for ; Mon, 13 Dec 2021 20:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=c+h3Ljxdzm8BQwJ5+vMGcrhGlWagJnPB8SRgTeEyRyE=; b=BhJxA/SEdoVvEIzj3K8dIJojXC44DE7PsX8B2Tuz42R2VjmqhJMGs10nAQRsqFtlSi G4mtlWH1tInHLcsysUl4UyZAcaVZNb19IebbzckCKdEMcYF3P0NAMzRQ7b80fzOckIUY ctgMhaytN7ohBO+gUDdiD9FFCbzhyIgBhlCl1OUvc7uwt/zEiMvrHHKhUpNPI7OuGioY 7CwFQQr5BFWt7OF3RFswCYyu7JnLFmiiEFwbYXpbTV0xAJU5mhAl/UQSnjr7yABqyb1Z d1YwRmYAJySGTWeX7++H5rdztZGqkseOUDRFnxIZz8K5ZTSilzQTqZYOSuMzE87eEdO2 /PQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=c+h3Ljxdzm8BQwJ5+vMGcrhGlWagJnPB8SRgTeEyRyE=; b=OsVs3tMH4qbOD6dHc5Hgc5S0JhYYhVp3N0/SD6J2n9ZgET6cod36PWqcmYdH+/Z5tb iE5vHHwsZV+xHoeWA/KiwFNH1BQyyh98lCo7X8D8xYoXVRFyx89WOj647ULGPPt1hgiR rVJ88NpldKSvCY5oVSOtAwqcnl3UvxruFyg9iSvOAvAgDCJbdGLTmd6w1Bfcf0cdJqa7 /pSLhklqtoT2WGcxK8e3BDVKup+NQKqbXkt1wCmnFIWTPp9mBaxIq/5bloo5QvZRbrAl fJb3iGuXudyFbIZsEB8fDWV3W08ud8pt+KZfcRt0/qHkL57NqHXMz9z0hvaoq2wr+zws pRgw== X-Gm-Message-State: AOAM530oPhkSL3UyoPgmN7oHMw4UI2LMSFZqbOAsENAxBuzxqExpPXNA /GAh7DkK/4jxtN2nozy3uss7mDdZkY8= X-Google-Smtp-Source: ABdhPJyta3M0d36/4rl+CPH3SEBWUkf9bhomfXpbIkzGbblRItALKFFC6hq46vSCkG9t8S52JODPtQ== X-Received: by 2002:a5d:680b:: with SMTP id w11mr2975504wru.345.1639454954967; Mon, 13 Dec 2021 20:09:14 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e7sm16122061wrg.31.2021.12.13.20.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:14 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:05 +0000 Subject: [PATCH v4 03/10] sparse-checkout: add sanity-checks on initial sparsity state Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Most sparse-checkout subcommands (list, add, reapply) only make sense when already in a sparse state. Add a quick check that will error out early if this is not the case. Also document with a comment why we do not exit early in `disable` even when core.sparseCheckout starts as false. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 20 ++++++++++++++++++++ t/t1091-sparse-checkout-builtin.sh | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index e252b82136e..eb8fbd36b0b 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -56,6 +56,9 @@ static int sparse_checkout_list(int argc, const char **argv) char *sparse_filename; int res; + if (!core_apply_sparse_checkout) + die(_("this worktree is not sparse")); + argc = parse_options(argc, argv, NULL, builtin_sparse_checkout_list_options, builtin_sparse_checkout_list_usage, 0); @@ -671,6 +674,9 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix) OPT_END(), }; + if (!core_apply_sparse_checkout) + die(_("no sparse-checkout to add to")); + repo_read_index(the_repository); argc = parse_options(argc, argv, prefix, @@ -719,6 +725,9 @@ static int sparse_checkout_reapply(int argc, const char **argv) OPT_END(), }; + if (!core_apply_sparse_checkout) + die(_("must be in a sparse-checkout to reapply sparsity patterns")); + argc = parse_options(argc, argv, NULL, builtin_sparse_checkout_reapply_options, builtin_sparse_checkout_reapply_usage, 0); @@ -740,6 +749,17 @@ static int sparse_checkout_disable(int argc, const char **argv) struct pattern_list pl; struct strbuf match_all = STRBUF_INIT; + /* + * We do not exit early if !core_apply_sparse_checkout; due to the + * ability for users to manually muck things up between + * direct editing of .git/info/sparse-checkout + * running read-tree -m u HEAD or update-index --skip-worktree + * direct toggling of config options + * users might end up with an index with SKIP_WORKTREE bit set on + * some files and not know how to undo it. So, here we just + * forcibly return to a dense checkout regardless of initial state. + */ + argc = parse_options(argc, argv, NULL, builtin_sparse_checkout_disable_options, builtin_sparse_checkout_disable_usage, 0); diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index 272ba1b566b..90a281bcf64 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -41,7 +41,15 @@ test_expect_success 'setup' ' ) ' -test_expect_success 'git sparse-checkout list (empty)' ' +test_expect_success 'git sparse-checkout list (not sparse)' ' + test_must_fail git -C repo sparse-checkout list >list 2>err && + test_must_be_empty list && + test_i18ngrep "this worktree is not sparse" err +' + +test_expect_success 'git sparse-checkout list (not sparse)' ' + git -C repo sparse-checkout set && + rm repo/.git/info/sparse-checkout && git -C repo sparse-checkout list >list 2>err && test_must_be_empty list && test_i18ngrep "this worktree is not sparse (sparse-checkout file may not exist)" err From patchwork Tue Dec 14 04:09:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBAA1C433F5 for ; Tue, 14 Dec 2021 04:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234014AbhLNEJX (ORCPT ); Mon, 13 Dec 2021 23:09:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233754AbhLNEJR (ORCPT ); Mon, 13 Dec 2021 23:09:17 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A39EC06173F for ; Mon, 13 Dec 2021 20:09:17 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id t18so30240340wrg.11 for ; Mon, 13 Dec 2021 20:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=KCDeweA+/ubYaoD9XQgWyyRMiO8wIWbgEtEFVicDa2A=; b=azh0LorksuRIQJTgcp4g3HZiwORq/TIRLN1lVsuou3oLi0qomjxiBuatMK3s8nGCW2 NAB1hEm7Pe0iD43YVMZn7uLNWvLVREVllXoibwPQ9m9Jqtes4r2ZhE2izRlwyIrmz8Eq iSyrniM0jRLMgp7nslPNvoTbE8pHrjHVt6+2G0ssuYPOdu0iSWV5sqhplwhK5ZJ8GJiw J5x97dYLTYIzDfrTJe0gypdY2PvQ0lIoj47iqtOhwxe7TGEMs8Qd2I9uvnJD1vEMtTFC m4kS7P5/w2ch5aHatdnsEp8r9GbIVVWD5V6X71yqOSbUsAYOvJYkLjKd/V2ZrOeSeFX7 FB6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=KCDeweA+/ubYaoD9XQgWyyRMiO8wIWbgEtEFVicDa2A=; b=sX43J91C9foZlzOLRBYsMdLildhw1lpMwmMNIHRhLuQeBWJMXidpNrLwwalwZPIf8c bcfxZclyhTuZ8W6GR2K1KsgJZdq8Fjfq4iEiRq72ZOI/GOy1f3mZL3JGqbLJmJZCybb8 SshvFe8JoWaLQyDhDqa6Hv9qyU1hBUYYWqu59xv60NeDS08lWlei2s/jGKB4rgVRiQNL C+fS9YS5szybN+zv4WePmmo3FvFY2OHBNgd5JbKXhouqFdNTnzBBpX61Qo7cv3IpODNz HJWqk9bbVE/HcxrV9YtsOY6C6egQMZx6Toa6mvtQzbQvzkPbZT8+FFWIi17dGzBswp7Y x/aA== X-Gm-Message-State: AOAM533x1l/cQK+A+Cgj9E+QBJn3c7t4VMd6MA+Wqp0RpPo2TQSiVzdC /mjxj82GqHAcxiYR4+jv3GVSY3cDrqc= X-Google-Smtp-Source: ABdhPJwiDH5hm1ozZx4cp9PnQp7tnwfxTuhU6zyGuEaP5hcX6wLzx/yTCDuTkYPcDFEFxZirJl1iTg== X-Received: by 2002:a5d:6b09:: with SMTP id v9mr2828668wrw.591.1639454955597; Mon, 13 Dec 2021 20:09:15 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u2sm14703034wrs.17.2021.12.13.20.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:15 -0800 (PST) Message-Id: <5882332b97f7766332ef5890e8bb8ee31b527fa2.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:06 +0000 Subject: [PATCH v4 04/10] sparse-checkout: disallow --no-stdin as an argument to set Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren We intentionally added --stdin as an option to `sparse-checkout set`, but didn't intend for --no-stdin to be permitted as well. Reported-by: Victoria Dye Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index eb8fbd36b0b..387903eafe7 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -699,8 +699,9 @@ static struct sparse_checkout_set_opts { static int sparse_checkout_set(int argc, const char **argv, const char *prefix) { static struct option builtin_sparse_checkout_set_options[] = { - OPT_BOOL(0, "stdin", &set_opts.use_stdin, - N_("read patterns from standard in")), + OPT_BOOL_F(0, "stdin", &set_opts.use_stdin, + N_("read patterns from standard in"), + PARSE_OPT_NONEG), OPT_END(), }; From patchwork Tue Dec 14 04:09:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8145BC433F5 for ; Tue, 14 Dec 2021 04:09:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233951AbhLNEJ0 (ORCPT ); Mon, 13 Dec 2021 23:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233806AbhLNEJS (ORCPT ); Mon, 13 Dec 2021 23:09:18 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A523DC061574 for ; Mon, 13 Dec 2021 20:09:17 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id p18so13338004wmq.5 for ; Mon, 13 Dec 2021 20:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=PGiJD1JW2LAfW4ipFuLomI28z7mSJwBE8j9UNJ/XZCI=; b=eVBmTrGUDtiKBA/xS53276qGLg9ZxTtRt+4MbS6KgcI8AHK2/1Ep2O44UptCClIMNU dzpL5ZgUyqPIerVtpGKmm2sx++9O7kcfc87kBlOPUZcfPRCE0GlvxCeLx3oS/Gs4YVBi kelhpSz/qxhGEnUEI2n7cocBL7VtUWFOQjDcul6aYl7cqt+qv1Bi57IaA5ObAia05bH/ sSe7IQxmuUVbJBsAQmRp2PXdgm401OyXv5DtS2OJ3Lu3nqOh45l0w91AMIMcJbGykHC2 7e3UTY9Aay9KB/C7PrOJXFNoqf5gK6BHbEglIPqyxwtTTVvZ/+bQcTwJvVFTBEjA2a3S KWHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=PGiJD1JW2LAfW4ipFuLomI28z7mSJwBE8j9UNJ/XZCI=; b=p5gKoOtNVkFQkOE0KgfFZNGqKqdi4GZnXC25FvLyjtmI+H0h3V/iMutHRb7TKFvzHs nthPKwZ0Gz5mR0nweer4HBdMBBCf030diqGxX80STGdxMSOIPAas3tZHwdGZBafv55dc afzdKDkg7G1TYy8TeaVA/4eGbGWQTBhYkpyTJyw4XFITJCcQGEYuinXeHZW1yX0XeLB9 9Mr+qECJVnIQ0oJap6chwSquuT/URp4QIcQ6jhfdzpm19U6343r4p8u37hm9Q+EXTtXn iWEzeK41qjuhpq914Z3N4M5yiL/Kgsaxx/IPXKhRwQ0aiyXOCDYgL2IqTiI8Knkji1Ou Ao0A== X-Gm-Message-State: AOAM5330UfsZvDPY1SNqF/rQBxZQQUaLckqsrLROpJdZq3YgJreMhB3T RGc/L/ClJnomkYEeq0hKjT0kDaTQ0ms= X-Google-Smtp-Source: ABdhPJzq19wGQyUi5h31+d5gtDAKSaKlXVR0Wc9DKtOq0kvg1tWLRXnqx9jRvFOfc/6iuDBAkHx03g== X-Received: by 2002:a1c:287:: with SMTP id 129mr43398076wmc.49.1639454956173; Mon, 13 Dec 2021 20:09:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z6sm12581073wrm.93.2021.12.13.20.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:15 -0800 (PST) Message-Id: <3e9e28c8dd2b2b4b3ba435eedf07f2b8b43d00fd.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:07 +0000 Subject: [PATCH v4 05/10] sparse-checkout: split out code for tweaking settings config Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren `init` has some code for handling updates to either cone mode or the sparse-index setting. We would like to be able to reuse this elsewhere, namely in `set` and `reapply`. Split this function out, and make it slightly more general so it can handle being called from the new callers. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 56 ++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 387903eafe7..3b74779bb48 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -383,6 +383,41 @@ static int set_config(enum sparse_checkout_mode mode) return 0; } +static int update_modes(int *cone_mode, int *sparse_index) +{ + int mode, record_mode; + + /* Determine if we need to record the mode; ensure sparse checkout on */ + record_mode = (*cone_mode != -1) || !core_apply_sparse_checkout; + + /* If not specified, use previous definition of cone mode */ + if (*cone_mode == -1 && core_apply_sparse_checkout) + *cone_mode = core_sparse_checkout_cone; + + /* Set cone/non-cone mode appropriately */ + core_apply_sparse_checkout = 1; + if (*cone_mode == 1) { + mode = MODE_CONE_PATTERNS; + core_sparse_checkout_cone = 1; + } else { + mode = MODE_ALL_PATTERNS; + } + if (record_mode && set_config(mode)) + return 1; + + /* Set sparse-index/non-sparse-index mode if specified */ + if (*sparse_index >= 0) { + if (set_sparse_index_config(the_repository, *sparse_index) < 0) + die(_("failed to modify sparse-index config")); + + /* force an index rewrite */ + repo_read_index(the_repository); + the_repository->index->updated_workdir = 1; + } + + return 0; +} + static char const * const builtin_sparse_checkout_init_usage[] = { N_("git sparse-checkout init [--cone] [--[no-]sparse-index]"), NULL @@ -399,7 +434,6 @@ static int sparse_checkout_init(int argc, const char **argv) char *sparse_filename; int res; struct object_id oid; - int mode; struct strbuf pattern = STRBUF_INIT; static struct option builtin_sparse_checkout_init_options[] = { @@ -412,19 +446,14 @@ static int sparse_checkout_init(int argc, const char **argv) repo_read_index(the_repository); + init_opts.cone_mode = -1; init_opts.sparse_index = -1; argc = parse_options(argc, argv, NULL, builtin_sparse_checkout_init_options, builtin_sparse_checkout_init_usage, 0); - if (init_opts.cone_mode) { - mode = MODE_CONE_PATTERNS; - core_sparse_checkout_cone = 1; - } else - mode = MODE_ALL_PATTERNS; - - if (set_config(mode)) + if (update_modes(&init_opts.cone_mode, &init_opts.sparse_index)) return 1; memset(&pl, 0, sizeof(pl)); @@ -432,17 +461,6 @@ static int sparse_checkout_init(int argc, const char **argv) sparse_filename = get_sparse_checkout_filename(); res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL, 0); - if (init_opts.sparse_index >= 0) { - if (set_sparse_index_config(the_repository, init_opts.sparse_index) < 0) - die(_("failed to modify sparse-index config")); - - /* force an index rewrite */ - repo_read_index(the_repository); - the_repository->index->updated_workdir = 1; - } - - core_apply_sparse_checkout = 1; - /* If we already have a sparse-checkout file, use it. */ if (res >= 0) { free(sparse_filename); From patchwork Tue Dec 14 04:09:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E0A0C433F5 for ; Tue, 14 Dec 2021 04:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234383AbhLNEJe (ORCPT ); Mon, 13 Dec 2021 23:09:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232880AbhLNEJT (ORCPT ); Mon, 13 Dec 2021 23:09:19 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53924C06173F for ; Mon, 13 Dec 2021 20:09:18 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id o29so13390459wms.2 for ; Mon, 13 Dec 2021 20:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ct1DndFFRiF7Tn13kqO+Louo5bwVR+lM58b4WOxSE4w=; b=dlt8sVbjWvmPiUmK+Qq+IagvlJMTGJmyKWQxOre6ggEUhrYqd100VwUWNGoyYouKiA Sk8BQWBbUHiS2jhzQ88fEaNBeuut6g/RxwRJIW89YkrPssgR1+YgWdh1oW5essCVWqAE LvampSR4xq5I8s1Q6xErU6mq9BAjPE3HmUi9sQz65CwpCU2+kjMSyxYRuvr6yUN9cOhj bNQN+hi3ykvXXts2+bFk+C5s82UnalK9Si1t/KjnKS/F1xPgSiI6USqaR/PlYiT0CmKq PjLOnpcJaE0/y8Hi2zHCyoY+BYk0VBO9BntNXCkKqr/ScMCmrtyqrnNCWii6Feb6JUdr iYWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ct1DndFFRiF7Tn13kqO+Louo5bwVR+lM58b4WOxSE4w=; b=hEilMi4NDnkry08yQiWEAOnspghGcMFR+xzeXKxwQE/4FB9TEdW139sLQDGficeJs0 vSd9CDfYAECd/TY+rZbE8yA16PlX/j3pvX0em9jqVPhijWUlUcWurM9UZKacjAu/IEix NYZoFPtd0phihCEeVJDPmIomlDI2VD7Eug4jo/DFJuAr+1LQD3+uvyUfnCPuwvdUV5Iv CG4bi8gh0Ng2ZOia4bJyKGRS73N5QdI0i40nDRqBu6Mthy265KM/72hw6HZCtXMzU76r /LbVMINXJf+rK5xoYKpZhwz/uPN2J3Wu6QLiJ9GvMStbU5sH+Wpenqc4mVv0b2nreKt7 l4IA== X-Gm-Message-State: AOAM533zddrgKtCzJfslXsijwZs3k1Ku5uiEK7IkvmebXX+HJUVBCRGq mgakBiP7B0hKy60yKTiQFmBd2S+LFdw= X-Google-Smtp-Source: ABdhPJynfaKqr3/17N7M6frK4rHvWsP0PWjlJmfzXk/L9yLyg6amqUOeAiVppbxzf2z6Abn7sL/Ubg== X-Received: by 2002:a1c:c917:: with SMTP id f23mr45219291wmb.10.1639454956768; Mon, 13 Dec 2021 20:09:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l2sm844292wmq.42.2021.12.13.20.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:16 -0800 (PST) Message-Id: <595ba13860352abcbd857c454c0b2d7e83efd6c0.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:08 +0000 Subject: [PATCH v4 06/10] sparse-checkout: enable `set` to initialize sparse-checkout mode Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The previously suggested workflow: git sparse-checkout init ... git sparse-checkout set ... Suffered from three problems: 1) It would delete nearly all files in the first step, then restore them in the second. That was poor performance and forced unnecessary rebuilds. 2) The two-step process resulted in two progress bars, which was suboptimal from a UI point of view for wrappers that invoked both of these commands but only exposed a single command to their end users. 3) With cone mode, the first step would delete nearly all ignored files everywhere, because everything was considered to be outside of the specified sparsity paths. (The user was not allowed to specify any sparsity paths in the `init` step.) Avoid these problems by teaching `set` to understand the extra parameters that `init` takes and performing any necessary initialization if not already in a sparse checkout. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 3b74779bb48..16daae84975 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -706,17 +706,26 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix) } static char const * const builtin_sparse_checkout_set_usage[] = { - N_("git sparse-checkout set (--stdin | )"), + N_("git sparse-checkout set [--[no-]cone] [--[no-]sparse-index] (--stdin | )"), NULL }; static struct sparse_checkout_set_opts { + int cone_mode; + int sparse_index; int use_stdin; } set_opts; static int sparse_checkout_set(int argc, const char **argv, const char *prefix) { + int default_patterns_nr = 2; + const char *default_patterns[] = {"/*", "!/*/", NULL}; + static struct option builtin_sparse_checkout_set_options[] = { + OPT_BOOL(0, "cone", &set_opts.cone_mode, + N_("initialize the sparse-checkout in cone mode")), + OPT_BOOL(0, "sparse-index", &set_opts.sparse_index, + N_("toggle the use of a sparse index")), OPT_BOOL_F(0, "stdin", &set_opts.use_stdin, N_("read patterns from standard in"), PARSE_OPT_NONEG), @@ -725,11 +734,27 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix) repo_read_index(the_repository); + set_opts.cone_mode = -1; + set_opts.sparse_index = -1; + argc = parse_options(argc, argv, prefix, builtin_sparse_checkout_set_options, builtin_sparse_checkout_set_usage, PARSE_OPT_KEEP_UNKNOWN); + if (update_modes(&set_opts.cone_mode, &set_opts.sparse_index)) + return 1; + + /* + * Cone mode automatically specifies the toplevel directory. For + * non-cone mode, if nothing is specified, manually select just the + * top-level directory (much as 'init' would do). + */ + if (!core_sparse_checkout_cone && argc == 0) { + argv = default_patterns; + argc = default_patterns_nr; + } + return modify_pattern_list(argc, argv, set_opts.use_stdin, REPLACE); } From patchwork Tue Dec 14 04:09:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B2B4C433EF for ; Tue, 14 Dec 2021 04:09:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234228AbhLNEJ2 (ORCPT ); Mon, 13 Dec 2021 23:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233828AbhLNEJT (ORCPT ); Mon, 13 Dec 2021 23:09:19 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B48C061574 for ; Mon, 13 Dec 2021 20:09:19 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id o29so13390469wms.2 for ; Mon, 13 Dec 2021 20:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=yJd7W6b5EpJPKt/oCPU9gfNGc/DAmWzP/z3eqsEVutI=; b=gW87z1HUFl3u7QzwWVe9KB0ygB5UYBUdbt8s8kt81qCVcwPgUmapUawSpQxUMqtucU sWYPhYWCPPc7MkQyF0Bgox1KaNELbWwJ9BJKcy1SAtrPtV9cc+WXC1h7qEOzvQTe5acN pEFjjM0jYqxPhFdA66xMSp4Qq8JER/uPrlLObUb/OKv/Kjo26+2jdzO3KkpoJ47lG1C8 1JZiAogOdNCnolcmaM5dExZDWsIsHfD4U32xpGsmgtiudBGKmJDf6xBZihnauv+L74UI uGMYR/OtU0g4bcdzixOgVcnnIt0aAeZLfiuXIKpAzHwpexsF08Btc9+snF7KSIy0C+fN kXHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=yJd7W6b5EpJPKt/oCPU9gfNGc/DAmWzP/z3eqsEVutI=; b=f+VdQhwAtvAJBysjot+P16foLG1XHfTE2J5lol3Z1bkWiCFgSz6ErA+w8CBa9NTy+u RzFwUGm9g2PkfwfTojOJ9i17zUxDAUcW3DSm8+G2CTm7GyXjglcSCUpFSa4c2CJv+aYv 2dToxWDTW9iF2v6sDc/THs55WOE1wwaO0bwf5Lxl0HK9dxJ3Uxw0rGqrAfNS3P5Ld6AZ gZoa27mGReLE2czYYAN0CkOWWGAffjjTeYqNyNpbTtm2wJe1N0fuWjpUuzb3WVfBrWYL dvF+j54HV/j/Fxzk1hcTeDPlwnYJmxRcV0KC2Ojr1mSOoWxFVK4G78Uuy6kmRlpjVUKB P2QQ== X-Gm-Message-State: AOAM533fzIWen09eNbiH2jHROeKzyQszSbnG0HPILiFrT/F/E6txeSob NWmAqJ2cU5umTZboJjK5HcO7F2QxsoA= X-Google-Smtp-Source: ABdhPJzkot28zgGW8KGZAuIt5MO82xtcu9GzMTA6AOIKz4DabbD4wGA6PnkPmikSkQ8R0BTufn0NUw== X-Received: by 2002:a1c:741a:: with SMTP id p26mr20507149wmc.133.1639454957319; Mon, 13 Dec 2021 20:09:17 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f8sm1581139wmf.2.2021.12.13.20.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:17 -0800 (PST) Message-Id: <09b13280c2619e9dcbf33422c5dcfba84f0e52be.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:09 +0000 Subject: [PATCH v4 07/10] sparse-checkout: enable reapply to take --[no-]{cone,sparse-index} Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Folks may want to switch to or from cone mode, or to or from a sparse-index without changing their sparsity paths. Allow them to do so using the reapply command. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/sparse-checkout.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 16daae84975..0dae44c5759 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -759,13 +759,22 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix) } static char const * const builtin_sparse_checkout_reapply_usage[] = { - N_("git sparse-checkout reapply"), + N_("git sparse-checkout reapply [--[no-]cone] [--[no-]sparse-index] "), NULL }; +static struct sparse_checkout_reapply_opts { + int cone_mode; + int sparse_index; +} reapply_opts; + static int sparse_checkout_reapply(int argc, const char **argv) { static struct option builtin_sparse_checkout_reapply_options[] = { + OPT_BOOL(0, "cone", &reapply_opts.cone_mode, + N_("initialize the sparse-checkout in cone mode")), + OPT_BOOL(0, "sparse-index", &reapply_opts.sparse_index, + N_("toggle the use of a sparse index")), OPT_END(), }; @@ -777,6 +786,13 @@ static int sparse_checkout_reapply(int argc, const char **argv) builtin_sparse_checkout_reapply_usage, 0); repo_read_index(the_repository); + + reapply_opts.cone_mode = -1; + reapply_opts.sparse_index = -1; + + if (update_modes(&reapply_opts.cone_mode, &reapply_opts.sparse_index)) + return 1; + return update_working_directory(NULL); } From patchwork Tue Dec 14 04:09:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0FF1C433EF for ; Tue, 14 Dec 2021 04:09:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233734AbhLNEJc (ORCPT ); Mon, 13 Dec 2021 23:09:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233860AbhLNEJU (ORCPT ); Mon, 13 Dec 2021 23:09:20 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4CDC061748 for ; Mon, 13 Dec 2021 20:09:19 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id o19-20020a1c7513000000b0033a93202467so12902624wmc.2 for ; Mon, 13 Dec 2021 20:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=q5HqGPHeqeZqnPsaVWCJV75wuALZkkRWQldk1Um9X34=; b=m+fnegMxnudBlPTlj5u7u9fPWKzGbR8zCMpnnJGQeLkhvKSU/RRA9JF4JpLfZkZT2K YQrR/LjmV0S3ZtfjjhGTORbjC+8Sa3OH4wbGy8t0D5TVwSuvshYVA7rHrXnZSgbzCrMn 2qrVzDcL1BU+1T3ND87FRHGAKhefKfMgoHGQnVklk24mYk1zGxZfB9rUKilmh/ZspKcJ XIsH3zIcNYvlduNlw93dx/Zk04hvKEePkiSyyLOJSg05TvmBwKjwWI5DdhJW+39pR2Em 04ZYjTe+LR731OgoCo5SPVGaz2wSJIfL7kWSxPdA2OkhY8bJhM7917slJnMnaWBnmO41 GEGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=q5HqGPHeqeZqnPsaVWCJV75wuALZkkRWQldk1Um9X34=; b=EFkxdK76ryEHdbU9a5FHbDMj4q9mSKbv8WhhX1FjP0LsOiwq4fM5lsIYTNKG1qZM3M qcBFjqrNV+TO3HgekOnk56Nlvcm0fSTY1DTH+7iHBgEXlIYBvIbC0SSQ9GusDatIizOa eEjx6k5y11y1Cjv0WHNaIG4oE7//VFjxuNBCjB96Xk4+MKrRfNOVESUqiRB/dZA+0Pyq pzESwYCMMTrYspEWhNFsAPIua0dHKPzeAtGRDXJXgk17o6Y6o99XzmUtijXSGLKN2Z0i 9yI6/XO8RpVgvzrpfZQ+xbTqWJo3Bv1S9MZ1wVGEHvduV/zgW5sdE228qGhVirAGvJpr k/0A== X-Gm-Message-State: AOAM531Sw48VgRzjmFBhzsDjnyjaFovpEXSwVP1aN4wz5XrZFSLGuab6 GKIasTTPUbL1GmtysWjw+ciiHWj9EKg= X-Google-Smtp-Source: ABdhPJz6EmrpM3wEx7TRDZAMhEpfntaHKGBb4NUw1vluPiKbOzvPJ9Z9FVxQheeXah2sLVvsFvEHCA== X-Received: by 2002:a05:600c:8a7:: with SMTP id l39mr509163wmp.138.1639454958062; Mon, 13 Dec 2021 20:09:18 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ay29sm815232wmb.44.2021.12.13.20.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:17 -0800 (PST) Message-Id: <9d96da855ea70e7e8a54bb68e710cc60a2f50376.1639454952.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:10 +0000 Subject: [PATCH v4 08/10] git-sparse-checkout.txt: update to document init/set/reapply changes Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren As noted in the previous commit, using separate `init` and `set` steps with sparse-checkout result in a number of issues. The previous commits made `set` able to handle the work of both commands, and enabled reapply to tweak the {cone,sparse-index} settings. Update the documentation to reflect this, and mark `init` as deprecated. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- Documentation/git-sparse-checkout.txt | 98 +++++++++++++++------------ 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/Documentation/git-sparse-checkout.txt b/Documentation/git-sparse-checkout.txt index 42056ee9ff9..72fcb6b2acc 100644 --- a/Documentation/git-sparse-checkout.txt +++ b/Documentation/git-sparse-checkout.txt @@ -30,28 +30,36 @@ COMMANDS 'list':: Describe the patterns in the sparse-checkout file. -'init':: - Enable the `core.sparseCheckout` setting. If the - sparse-checkout file does not exist, then populate it with - patterns that match every file in the root directory and - no other directories, then will remove all directories tracked - by Git. Add patterns to the sparse-checkout file to - repopulate the working directory. +'set':: + Enable the necessary config settings + (extensions.worktreeConfig, core.sparseCheckout, + core.sparseCheckoutCone) if they are not already enabled, and + write a set of patterns to the sparse-checkout file from the + list of arguments following the 'set' subcommand. Update the + working directory to match the new patterns. + -To avoid interfering with other worktrees, it first enables the -`extensions.worktreeConfig` setting and makes sure to set the -`core.sparseCheckout` setting in the worktree-specific config file. +When the `--stdin` option is provided, the patterns are read from +standard in as a newline-delimited list instead of from the arguments. + -When `--cone` is provided, the `core.sparseCheckoutCone` setting is -also set, allowing for better performance with a limited set of -patterns (see 'CONE PATTERN SET' below). +When `--cone` is passed or `core.sparseCheckoutCone` is enabled, the +input list is considered a list of directories instead of +sparse-checkout patterns. This allows for better performance with a +limited set of patterns (see 'CONE PATTERN SET' below). Note that the +set command will write patterns to the sparse-checkout file to include +all files contained in those directories (recursively) as well as +files that are siblings of ancestor directories. The input format +matches the output of `git ls-tree --name-only`. This includes +interpreting pathnames that begin with a double quote (") as C-style +quoted strings. This may become the default in the future; --no-cone +can be passed to request non-cone mode. + -Use the `--[no-]sparse-index` option to toggle the use of the sparse -index format. This reduces the size of the index to be more closely -aligned with your sparse-checkout definition. This can have significant -performance advantages for commands such as `git status` or `git add`. -This feature is still experimental. Some commands might be slower with -a sparse index until they are properly integrated with the feature. +Use the `--[no-]sparse-index` option to use a sparse index (the +default is to not use it). A sparse index reduces the size of the +index to be more closely aligned with your sparse-checkout +definition. This can have significant performance advantages for +commands such as `git status` or `git add`. This feature is still +experimental. Some commands might be slower with a sparse index until +they are properly integrated with the feature. + **WARNING:** Using a sparse index requires modifying the index in a way that is not completely understood by external tools. If you have trouble @@ -60,23 +68,6 @@ to rewrite your index to not be sparse. Older versions of Git will not understand the sparse directory entries index extension and may fail to interact with your repository until it is disabled. -'set':: - Write a set of patterns to the sparse-checkout file, as given as - a list of arguments following the 'set' subcommand. Update the - working directory to match the new patterns. Enable the - core.sparseCheckout config setting if it is not already enabled. -+ -When the `--stdin` option is provided, the patterns are read from -standard in as a newline-delimited list instead of from the arguments. -+ -When `core.sparseCheckoutCone` is enabled, the input list is considered a -list of directories instead of sparse-checkout patterns. The command writes -patterns to the sparse-checkout file to include all files contained in those -directories (recursively) as well as files that are siblings of ancestor -directories. The input format matches the output of `git ls-tree --name-only`. -This includes interpreting pathnames that begin with a double quote (") as -C-style quoted strings. - 'add':: Update the sparse-checkout file to include additional patterns. By default, these patterns are read from the command-line arguments, @@ -93,12 +84,35 @@ C-style quoted strings. cases, it can make sense to run `git sparse-checkout reapply` later after cleaning up affected paths (e.g. resolving conflicts, undoing or committing changes, etc.). ++ +The `reapply` command can also take `--[no-]cone` and `--[no-]sparse-index` +flags, with the same meaning as the flags from the `set` command, in order +to change which sparsity mode you are using without needing to also respecify +all sparsity paths. 'disable':: Disable the `core.sparseCheckout` config setting, and restore the - working directory to include all files. Leaves the sparse-checkout - file intact so a later 'git sparse-checkout init' command may - return the working directory to the same state. + working directory to include all files. + +'init':: + Deprecated command that behaves like `set` with no specified paths. + May be removed in the future. ++ +Historically, `set` did not handle all the necessary config settings, +which meant that both `init` and `set` had to be called. Invoking +both meant the `init` step would first remove nearly all tracked files +(and in cone mode, ignored files too), then the `set` step would add +many of the tracked files (but not ignored files) back. In addition +to the lost files, the performance and UI of this combination was +poor. ++ +Also, historically, `init` would not actually initialize the +sparse-checkout file if it already existed. This meant it was +possible to return to a sparse-checkout without remembering which +paths to pass to a subsequent 'set' or 'add' command. However, +`--cone` and `--sparse-index` options would not be remembered across +the disable command, so the easy restore of calling a plain `init` +decreased in utility. SPARSE CHECKOUT --------------- @@ -117,10 +131,8 @@ directory, it updates the skip-worktree bits in the index based on this file. The files matching the patterns in the file will appear in the working directory, and the rest will not. -To enable the sparse-checkout feature, run `git sparse-checkout init` to -initialize a simple sparse-checkout file and enable the `core.sparseCheckout` -config setting. Then, run `git sparse-checkout set` to modify the patterns in -the sparse-checkout file. +To enable the sparse-checkout feature, run `git sparse-checkout set` to +set the patterns you want to use. To repopulate the working directory with all files, use the `git sparse-checkout disable` command. From patchwork Tue Dec 14 04:09:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0DFCC433FE for ; Tue, 14 Dec 2021 04:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233828AbhLNEJa (ORCPT ); Mon, 13 Dec 2021 23:09:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbhLNEJU (ORCPT ); Mon, 13 Dec 2021 23:09:20 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57BEEC061751 for ; Mon, 13 Dec 2021 20:09:20 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id v11so30257969wrw.10 for ; Mon, 13 Dec 2021 20:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=5VRL/COZrrE2C/RlI8KN2PlRId4Ot6isrchZ2ZL3zR4=; b=Tec4P6crLpoCWrzas2AqGWbRcBcY6NEQl3+XH40RZumD8V2Tf/KejcBX7fZ46QmE2z nj14E3H7J9MkN4lzdJObvboBsoCcGD68BABwFqHEuV7z4sHDwwwgP+dWeyVbtyEQD57w BXlH+g61RcJHcGk+HDLqzqcmkIzXKDTJQZggj5jGPzoht4GUV1k5yc6PVdt23afZxNB0 gqxK6Dpx21PxwO5GxGKwBvWwE+a4hfIVc+yQyBL9IVN9QI40bBvvf41u7/wZUkM+5C2J 50d4cLEHE+TnJ58+1dPaapXjlrwxwgtzyI3s763oKhcE7fYM5QH+mKdp93HXQeDJt6/M EKSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=5VRL/COZrrE2C/RlI8KN2PlRId4Ot6isrchZ2ZL3zR4=; b=mIiS//ACGyH6nNAg6uWcEmOBKT2DdjL2ypFcs240FyOLwimknlNMwuGKZ2uSlhkPk6 DtSyFBElcI1PKtj1z+Ifdc6Kg9JQzz9Jr9LG0gNVCnOJ5xjhov9VnRvoSm1Bhara8ymc b/7PVH5SsKlQXwzFVTvlOr2GNRctZJvbD4RZ3I22aHhi/QUjpv3q24lSA5uY9V8U+9HH y6RCDPWs4fAxG5GFlT3PsGycYZBWAlIdZHRXwvTqxuaY8QnhXrseQGpnZMu6gPaTW/Bc S1JebOY6mW1dT+dWuN4miZ3ZArdwFFMYsZ3OGq2cmBc9oOkO3becZH0yoTWKXl4BDCjp HwDw== X-Gm-Message-State: AOAM5302wQZpSL5GSPRyxgKcyAlXFjpzEhQeXPcFU2Uzucjw1L0ougv8 ahdJYnocFJAUbyXo9/YB7aWCn9SJ6Bc= X-Google-Smtp-Source: ABdhPJxZk7ePP+qwG6UTpStOYlUtbRVeY1Hb93TPp2uL1XBn5ZWCjGwulT7OroFLRU+4x/diIMNPVQ== X-Received: by 2002:a5d:4901:: with SMTP id x1mr2915423wrq.473.1639454958776; Mon, 13 Dec 2021 20:09:18 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w8sm10112725wre.106.2021.12.13.20.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:18 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:11 +0000 Subject: [PATCH v4 09/10] Documentation: clarify/correct a few sparsity related statements Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- Documentation/git-clone.txt | 8 ++++---- Documentation/git-sparse-checkout.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 3fe3810f1ce..b348a71fc68 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -167,10 +167,10 @@ objects from the source repository into a pack in the cloned repository. configuration variables are created. --sparse:: - Initialize the sparse-checkout file so the working - directory starts with only the files in the root - of the repository. The sparse-checkout file can be - modified to grow the working directory as needed. + Employ a sparse-checkout, with only files in the toplevel + directory initially being present. The + linkgit:git-sparse-checkout[1] command can be used to grow the + working directory as needed. --filter=:: Use the partial clone feature and request that the server sends diff --git a/Documentation/git-sparse-checkout.txt b/Documentation/git-sparse-checkout.txt index 72fcb6b2acc..9a4b43c105b 100644 --- a/Documentation/git-sparse-checkout.txt +++ b/Documentation/git-sparse-checkout.txt @@ -121,7 +121,7 @@ SPARSE CHECKOUT It uses the skip-worktree bit (see linkgit:git-update-index[1]) to tell Git whether a file in the working directory is worth looking at. If the skip-worktree bit is set, then the file is ignored in the working -directory. Git will not populate the contents of those files, which +directory. Git will avoid populating the contents of those files, which makes a sparse checkout helpful when working in a repository with many files, but only a few are important to the current user. From patchwork Tue Dec 14 04:09:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12675453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8E04C433F5 for ; Tue, 14 Dec 2021 04:09:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233873AbhLNEJg (ORCPT ); Mon, 13 Dec 2021 23:09:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbhLNEJV (ORCPT ); Mon, 13 Dec 2021 23:09:21 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E357DC06173F for ; Mon, 13 Dec 2021 20:09:20 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d24so30426710wra.0 for ; Mon, 13 Dec 2021 20:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=y3fl9hDWXuCSYMuW6+ZA/aC18Vkow8+QcGnZipJ9ido=; b=G+p43dvciZFLLIFHBV2+iXvOpQmX2WrcNBvmBWttzKkJN9w1HOWtx1kSwKgnjMAaLD dnum9BzkvoN7rR0EpSVDOm3Dxah46MYa43m+bGM4xBnVh+zRht0Swo+v7jX8M1WjpCgT UtZeieQJIo/b4p3V6RCR4dsE2xTb4wBg5DBIRk9M4S/nLc9vQQV6cTLiPpWQl3Fwqaz7 2QSEEMlBjEXaSW51RnZTJdBreyKDtRrT+/9nQlr8sZdEg44plk/iylcHbMSAzVfRVRax SZOLYLEcD6+U+yMJYOkjG1XnEytzZzxDSpJ80L/la6vKCZeJonHNHq3lsI6elHn4aOI2 /zxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=y3fl9hDWXuCSYMuW6+ZA/aC18Vkow8+QcGnZipJ9ido=; b=U0a3fS7R8IAGKarAriW80nAaBSp8TmfqvHseLQBY5FoRM5ix1DwPmo1NYPxp6lzcRr L4ZgjVplrp3YalLWFqsGgeT4bepH+legGt5B7BgYj7B8PH2l3lrlaKh3JFbNUt5tPJDb lGWnHQjXKEmjSok5szqcKO6UZm+wtEQUXHT4YYFBBySCwcYjZd/RKjHArSHaFCA4tdBc SrKQz5OYsSCjsVeOQQkajHkjrmUzgkoivxlkdne/hkmOJkNpQUfUwBpcvu46nECigKaD tgcNdg3yHpVxJIgoVlkO9KB+qkjwdTP20tTYV1lAisiSWsabDfvpE5qIkGDnxtdH6mKb kLUQ== X-Gm-Message-State: AOAM532TH7eo+IiV3VQANXwl9f4agLhAfKts1eToqm9SkfVe8L5MLU2T viXjfTexBUcqCwkLKpxpCvTuIgkYa8Q= X-Google-Smtp-Source: ABdhPJwjMLhlMs+Idyidcoo8dTUTAsiVwKWmZ7boF7hFOnU6m4O2pGwrtBlYkgNGCHkjZmD29unjdA== X-Received: by 2002:adf:d4c2:: with SMTP id w2mr3018197wrk.225.1639454959441; Mon, 13 Dec 2021 20:09:19 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n13sm12575855wrt.44.2021.12.13.20.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 20:09:19 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 14 Dec 2021 04:09:12 +0000 Subject: [PATCH v4 10/10] clone: avoid using deprecated `sparse-checkout init` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Lessley Dennington , Victoria Dye , Elijah Newren , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The previous commits marked `sparse-checkout init` as deprecated; we can just use `set` instead here and pass it no paths. Reviewed-by: Derrick Stolee Reviewed-by: Victoria Dye Signed-off-by: Elijah Newren --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/clone.c b/builtin/clone.c index fb377b27657..5bed37f8b51 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -633,7 +633,7 @@ static int git_sparse_checkout_init(const char *repo) { struct strvec argv = STRVEC_INIT; int result = 0; - strvec_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL); + strvec_pushl(&argv, "-C", repo, "sparse-checkout", "set", NULL); /* * We must apply the setting in the current process