git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] sparse-checkout: use default patterns for 'set' only !stdin

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2023, 06:59 UTC
Message-ID
<20231221065925.3234048-3-gitster@pobox.com>
In-Reply-To
<20231221065925.3234048-1-gitster@pobox.com>

"git sparse-checkout set ---no-cone" uses default patterns when none is given from the command line, but it should do so ONLY when --stdin is not being used. Right now, add_patterns_from_input() called when reading from the standard input is sloppy and does not check if there are extra command line parameters that the command will silently ignore, but that will change soon and not setting this unnecessary and unused default patterns start to matter when it gets fixed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This came from f2e3a218 (sparse-checkout: enable `set` to
   initialize sparse-checkout mode, 2021-12-14) by Elijah.
 builtin/sparse-checkout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 8f55127202..04ae81fce8 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -837,7 +837,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
 	 * 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) {
+	if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {
 		argv = default_patterns;
 		argc = default_patterns_nr;
 	} else {
-- 
2.43.0-174-g055bb6e996
Previous: Junio C HamanoNext: Elijah Newren
Message 2 of 7 in “sparse-checkout with --end-of-options”
  1. 0/3 sparse-checkout with --end-of-optionsJunio C Hamano, Dec 21, 2023
  2. 2/3 sparse-checkout: use default patterns for 'set' only !stdinJunio C Hamano, Dec 21, 2023
  3. Elijah NewrenDec 24, 2023
  4. Junio C HamanoDec 28, 2023
  5. 3/3 sparse-checkout: tighten add_patterns_from_input()Junio C Hamano, Dec 21, 2023
  6. 1/3 sparse-checkout: take care of "--end-of-options" in set/add/check-rulesJunio C Hamano, Dec 21, 2023
  7. Elijah NewrenDec 24, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.