{"thread":{"id":"60642","subject":"[PATCH 2/3] sparse-checkout: use default patterns for 'set' only !stdin","startedAt":"2023-12-21T06:59:35Z","lastAt":"2023-12-28T00:19:03Z","messageCount":7,"participants":["Junio C Hamano","Elijah Newren"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"485903","messageId":"20231221065925.3234048-3-gitster@pobox.com","threadId":"60642","inReplyTo":"20231221065925.3234048-1-gitster@pobox.com","subject":"[PATCH 2/3] sparse-checkout: use default patterns for 'set' only !stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-21T06:59:24Z","receivedAt":"2023-12-21T06:59:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git sparse-checkout set ---no-cone\" uses default patterns when none\nis given from the command line, but it should do so ONLY when\n--stdin is not being used.  Right now, add_patterns_from_input()\ncalled when reading from the standard input is sloppy and does not\ncheck if there are extra command line parameters that the command\nwill silently ignore, but that will change soon and not setting this\nunnecessary and unused default patterns start to matter when it gets\nfixed.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n * This came from f2e3a218 (sparse-checkout: enable `set` to\n   initialize sparse-checkout mode, 2021-12-14) by Elijah.\n\n builtin/sparse-checkout.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 8f55127202..04ae81fce8 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -837,7 +837,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n \t * non-cone mode, if nothing is specified, manually select just the\n \t * top-level directory (much as 'init' would do).\n \t */\n-\tif (!core_sparse_checkout_cone && argc == 0) {\n+\tif (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {\n \t\targv = default_patterns;\n \t\targc = default_patterns_nr;\n \t} else {\n-- \n2.43.0-174-g055bb6e996\n\n"},{"id":"485904","messageId":"20231221065925.3234048-1-gitster@pobox.com","threadId":"60642","inReplyTo":null,"subject":"[PATCH 0/3] sparse-checkout with --end-of-options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-21T06:59:22Z","receivedAt":"2023-12-21T06:59:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I only wanted to make sure \n\n    git sparse-checkout set --end-of-options path\n\nwork fine, but it turns out that there were other sloppiness that\nhas nothing to do with the end-of-options handling that needs to be\nadjusted to the new world order, so I ended up addressing that as\nwell.\n\nJunio C Hamano (3):\n  sparse-checkout: take care of \"--end-of-options\" in set/add\n  sparse-checkout: allow default patterns for 'set' only !stdin\n  sparse-checkout: tighten add_patterns_from_input()\n\n builtin/sparse-checkout.c          |  9 ++++++++-\n parse-options.c                    |  8 ++++++++\n parse-options.h                    |  2 ++\n t/t1090-sparse-checkout-scope.sh   |  8 ++++++++\n t/t1091-sparse-checkout-builtin.sh | 13 +++++++++++--\n 5 files changed, 37 insertions(+), 3 deletions(-)\n\n-- \n2.43.0-174-g055bb6e996\n\n"},{"id":"485905","messageId":"20231221065925.3234048-4-gitster@pobox.com","threadId":"60642","inReplyTo":"20231221065925.3234048-1-gitster@pobox.com","subject":"[PATCH 3/3] sparse-checkout: tighten add_patterns_from_input()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-21T06:59:25Z","receivedAt":"2023-12-21T06:59:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The add_patterns_from_input() function was introduced at 6fb705ab\n(sparse-checkout: extract add_patterns_from_input(), 2020-02-11) and\nthen modified by 00408ade (builtin/sparse-checkout: add check-rules\ncommand, 2023-03-27).  Throughout its life, it either allowed to\nread patterns from the file (before 00408ade, it only allowed the\nstandard input, after 00408ade, an arbitrary FILE *) or from argv[],\nbut never both.  However, when we read from a file, the function\nnever checked that there is nothing in argv[] (in other words, the\ncommand line arguments have fully been consumed), resulting in\nexcess arguments silently getting ignored.\n\nThis caused commands like \"git sparse-checkout set [--stdin]\" and\n\"git sparse-checkout check-rules [--rules-file <file>]\" to silently\nignore the rest of the command line arguments without reporting.\n\nThe fix finally makes the --end-of-options handling for this\nsubcommand also work, so add test for it, too.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/sparse-checkout.c          |  4 ++++\n t/t1091-sparse-checkout-builtin.sh | 11 ++++++++++-\n 2 files changed, 14 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 04ae81fce8..1166e1e298 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -555,6 +555,10 @@ static void add_patterns_from_input(struct pattern_list *pl,\n \t\t\t\t    FILE *file)\n {\n \tint i;\n+\n+\tif (file && argc)\n+\t\tdie(_(\"excess command line parameter '%s'\"), argv[0]);\n+\n \tif (core_sparse_checkout_cone) {\n \t\tstruct strbuf line = STRBUF_INIT;\n \ndiff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh\nindex e33a6ed1b4..107ed170ac 100755\n--- a/t/t1091-sparse-checkout-builtin.sh\n+++ b/t/t1091-sparse-checkout-builtin.sh\n@@ -937,6 +937,10 @@ test_expect_success 'check-rules cone mode' '\n \tEOF\n \n \tgit -C bare ls-tree -r --name-only HEAD >all-files &&\n+\n+\ttest_must_fail git -C bare sparse-checkout check-rules --cone \\\n+\t\t--rules-file ../rules excess args <all-files &&\n+\n \tgit -C bare sparse-checkout check-rules --cone \\\n \t\t--rules-file ../rules >check-rules-file <all-files &&\n \n@@ -947,6 +951,7 @@ test_expect_success 'check-rules cone mode' '\n \tgit -C repo sparse-checkout check-rules >check-rules-default <all-files &&\n \n \ttest_grep \"deep/deeper1/deepest/a\" check-rules-file &&\n+\ttest_grep ! \"end-of-options\" check-rules-file &&\n \ttest_grep ! \"deep/deeper2\" check-rules-file &&\n \n \ttest_cmp check-rules-file ls-files &&\n@@ -959,8 +964,12 @@ test_expect_success 'check-rules non-cone mode' '\n \tEOF\n \n \tgit -C bare ls-tree -r --name-only HEAD >all-files &&\n+\n+\ttest_must_fail git -C bare sparse-checkout check-rules --no-cone \\\n+\t\t--rules-file ../rules excess args <all-files &&\n+\n \tgit -C bare sparse-checkout check-rules --no-cone --rules-file ../rules\\\n-\t\t>check-rules-file <all-files &&\n+\t\t--end-of-options >check-rules-file <all-files &&\n \n \tcat rules | git -C repo sparse-checkout set --no-cone --stdin &&\n \tgit -C repo ls-files -t >out &&\n-- \n2.43.0-174-g055bb6e996\n\n"},{"id":"485906","messageId":"20231221065925.3234048-2-gitster@pobox.com","threadId":"60642","inReplyTo":"20231221065925.3234048-1-gitster@pobox.com","subject":"[PATCH 1/3] sparse-checkout: take care of \"--end-of-options\" in set/add/check-rules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-21T06:59:23Z","receivedAt":"2023-12-21T06:59:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"93851746 (parse-options: decouple \"--end-of-options\" and \"--\",\n2023-12-06) updated the world order to make callers of parse-options\nthat set PARSE_OPT_KEEP_UNKNOWN_OPT responsible for deciding what to\ndo with \"--end-of-options\" they may see after parse_options() returns.\n\nThis unfortunately broke \"sparse-checkout set/add\", and from this\ninvocation,\n\n  \"git sparse-checkout [add|set] --[no-]cone --end-of-options pattern...\"\n\nwe now see \"--end-of-options\" listed in .git/info/sparse-checkout as if\nit is one of the path patterns.\n\nA breakage that results from the same cause exists in the check-rules\nsubcommand, but check-rules has a few other problems that need to be\ncorrected before it can fully work with --end-of-options safely,\nwhich will be addressed later.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/sparse-checkout.c          | 3 +++\n parse-options.c                    | 8 ++++++++\n parse-options.h                    | 2 ++\n t/t1090-sparse-checkout-scope.sh   | 8 ++++++++\n t/t1091-sparse-checkout-builtin.sh | 2 +-\n 5 files changed, 22 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 5c8ffb1f75..8f55127202 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -779,6 +779,7 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_sparse_checkout_add_options,\n \t\t\t     builtin_sparse_checkout_add_usage,\n \t\t\t     PARSE_OPT_KEEP_UNKNOWN_OPT);\n+\tparse_opt_skip_end_of_options(&argc, &argv);\n \n \tsanitize_paths(argc, argv, prefix, add_opts.skip_checks);\n \n@@ -826,6 +827,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_sparse_checkout_set_options,\n \t\t\t     builtin_sparse_checkout_set_usage,\n \t\t\t     PARSE_OPT_KEEP_UNKNOWN_OPT);\n+\tparse_opt_skip_end_of_options(&argc, &argv);\n \n \tif (update_modes(&set_opts.cone_mode, &set_opts.sparse_index))\n \t\treturn 1;\n@@ -998,6 +1000,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *\n \t\t\t     builtin_sparse_checkout_check_rules_options,\n \t\t\t     builtin_sparse_checkout_check_rules_usage,\n \t\t\t     PARSE_OPT_KEEP_UNKNOWN_OPT);\n+\tparse_opt_skip_end_of_options(&argc, &argv);\n \n \tif (check_rules_opts.rules_file && check_rules_opts.cone_mode < 0)\n \t\tcheck_rules_opts.cone_mode = 1;\ndiff --git a/parse-options.c b/parse-options.c\nindex d50962062e..fe265bbf68 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -1321,3 +1321,11 @@ void die_for_incompatible_opt4(int opt1, const char *opt1_name,\n \t\tbreak;\n \t}\n }\n+\n+void parse_opt_skip_end_of_options(int *argc, const char ***argv)\n+{\n+\tif (*argc && !strcmp(**argv, \"--end-of-options\")) {\n+\t\t(*argc)--;\n+\t\t(*argv)++;\n+\t}\n+}\ndiff --git a/parse-options.h b/parse-options.h\nindex bd62e20268..0d3354d4a8 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -498,6 +498,8 @@ int parse_opt_passthru_argv(const struct option *, const char *, int);\n /* value is enum branch_track* */\n int parse_opt_tracking_mode(const struct option *, const char *, int);\n \n+void parse_opt_skip_end_of_options(int *argc, const char ***argv);\n+\n #define OPT__VERBOSE(var, h)  OPT_COUNTUP('v', \"verbose\", (var), (h))\n #define OPT__QUIET(var, h)    OPT_COUNTUP('q', \"quiet\",   (var), (h))\n #define OPT__VERBOSITY(var) { \\\ndiff --git a/t/t1090-sparse-checkout-scope.sh b/t/t1090-sparse-checkout-scope.sh\nindex 3a14218b24..5b96716235 100755\n--- a/t/t1090-sparse-checkout-scope.sh\n+++ b/t/t1090-sparse-checkout-scope.sh\n@@ -57,6 +57,14 @@ test_expect_success 'return to full checkout of main' '\n test_expect_success 'skip-worktree on files outside sparse patterns' '\n \tgit sparse-checkout disable &&\n \tgit sparse-checkout set --no-cone \"a*\" &&\n+\tcat .git/info/sparse-checkout >wo-eoo &&\n+\n+\tgit sparse-checkout disable &&\n+\tgit sparse-checkout set --no-cone --end-of-options \"a*\" &&\n+\tcat .git/info/sparse-checkout >w-eoo &&\n+\n+\ttest_cmp wo-eoo w-eoo &&\n+\n \tgit checkout-index --all --ignore-skip-worktree-bits &&\n \n \tgit ls-files -t >output &&\ndiff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh\nindex f67611da28..e33a6ed1b4 100755\n--- a/t/t1091-sparse-checkout-builtin.sh\n+++ b/t/t1091-sparse-checkout-builtin.sh\n@@ -334,7 +334,7 @@ test_expect_success 'cone mode: set with nested folders' '\n \n test_expect_success 'cone mode: add independent path' '\n \tgit -C repo sparse-checkout set deep/deeper1 &&\n-\tgit -C repo sparse-checkout add folder1 &&\n+\tgit -C repo sparse-checkout add --end-of-options folder1 &&\n \tcat >expect <<-\\EOF &&\n \t/*\n \t!/*/\n-- \n2.43.0-174-g055bb6e996\n\n"},{"id":"486010","messageId":"CABPp-BF3Vqq8Y8+2pQyO7-StUVPR3as+Q_aL+o92ydoJY-8zEw@mail.gmail.com","threadId":"60642","inReplyTo":"20231221065925.3234048-3-gitster@pobox.com","subject":"Re: [PATCH 2/3] sparse-checkout: use default patterns for 'set' only !stdin","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2023-12-24T07:51:19Z","receivedAt":"2023-12-24T07:51:31Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Dec 20, 2023 at 10:59 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"git sparse-checkout set ---no-cone\" uses default patterns when none\n> is given from the command line, but it should do so ONLY when\n> --stdin is not being used.  Right now, add_patterns_from_input()\n> called when reading from the standard input is sloppy and does not\n> check if there are extra command line parameters that the command\n> will silently ignore, but that will change soon and not setting this\n> unnecessary and unused default patterns start to matter when it gets\n> fixed.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  * This came from f2e3a218 (sparse-checkout: enable `set` to\n>    initialize sparse-checkout mode, 2021-12-14) by Elijah.\n>\n>  builtin/sparse-checkout.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\n> index 8f55127202..04ae81fce8 100644\n> --- a/builtin/sparse-checkout.c\n> +++ b/builtin/sparse-checkout.c\n> @@ -837,7 +837,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n>          * non-cone mode, if nothing is specified, manually select just the\n>          * top-level directory (much as 'init' would do).\n>          */\n> -       if (!core_sparse_checkout_cone && argc == 0) {\n> +       if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {\n>                 argv = default_patterns;\n>                 argc = default_patterns_nr;\n>         } else {\n> --\n> 2.43.0-174-g055bb6e996\n\nThanks for catching this; the fix looks good to me.\n"},{"id":"486011","messageId":"CABPp-BGk-B4iVa7ZubNVoWRtJgg4guK31ctdO16osUnn7bRhHQ@mail.gmail.com","threadId":"60642","inReplyTo":"20231221065925.3234048-2-gitster@pobox.com","subject":"Re: [PATCH 1/3] sparse-checkout: take care of \"--end-of-options\" in set/add/check-rules","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2023-12-24T07:53:04Z","receivedAt":"2023-12-24T07:53:17Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Dec 20, 2023 at 11:00 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> 93851746 (parse-options: decouple \"--end-of-options\" and \"--\",\n> 2023-12-06) updated the world order to make callers of parse-options\n> that set PARSE_OPT_KEEP_UNKNOWN_OPT responsible for deciding what to\n> do with \"--end-of-options\" they may see after parse_options() returns.\n>\n> This unfortunately broke \"sparse-checkout set/add\", and from this\n> invocation,\n>\n>   \"git sparse-checkout [add|set] --[no-]cone --end-of-options pattern...\"\n>\n> we now see \"--end-of-options\" listed in .git/info/sparse-checkout as if\n> it is one of the path patterns.\n>\n> A breakage that results from the same cause exists in the check-rules\n> subcommand, but check-rules has a few other problems that need to be\n> corrected before it can fully work with --end-of-options safely,\n> which will be addressed later.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  builtin/sparse-checkout.c          | 3 +++\n>  parse-options.c                    | 8 ++++++++\n>  parse-options.h                    | 2 ++\n>  t/t1090-sparse-checkout-scope.sh   | 8 ++++++++\n>  t/t1091-sparse-checkout-builtin.sh | 2 +-\n>  5 files changed, 22 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\n> index 5c8ffb1f75..8f55127202 100644\n> --- a/builtin/sparse-checkout.c\n> +++ b/builtin/sparse-checkout.c\n> @@ -779,6 +779,7 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix)\n>                              builtin_sparse_checkout_add_options,\n>                              builtin_sparse_checkout_add_usage,\n>                              PARSE_OPT_KEEP_UNKNOWN_OPT);\n> +       parse_opt_skip_end_of_options(&argc, &argv);\n>\n>         sanitize_paths(argc, argv, prefix, add_opts.skip_checks);\n>\n> @@ -826,6 +827,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n>                              builtin_sparse_checkout_set_options,\n>                              builtin_sparse_checkout_set_usage,\n>                              PARSE_OPT_KEEP_UNKNOWN_OPT);\n> +       parse_opt_skip_end_of_options(&argc, &argv);\n>\n>         if (update_modes(&set_opts.cone_mode, &set_opts.sparse_index))\n>                 return 1;\n> @@ -998,6 +1000,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *\n>                              builtin_sparse_checkout_check_rules_options,\n>                              builtin_sparse_checkout_check_rules_usage,\n>                              PARSE_OPT_KEEP_UNKNOWN_OPT);\n> +       parse_opt_skip_end_of_options(&argc, &argv);\n>\n>         if (check_rules_opts.rules_file && check_rules_opts.cone_mode < 0)\n>                 check_rules_opts.cone_mode = 1;\n> diff --git a/parse-options.c b/parse-options.c\n> index d50962062e..fe265bbf68 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -1321,3 +1321,11 @@ void die_for_incompatible_opt4(int opt1, const char *opt1_name,\n>                 break;\n>         }\n>  }\n> +\n> +void parse_opt_skip_end_of_options(int *argc, const char ***argv)\n> +{\n> +       if (*argc && !strcmp(**argv, \"--end-of-options\")) {\n> +               (*argc)--;\n> +               (*argv)++;\n> +       }\n> +}\n> diff --git a/parse-options.h b/parse-options.h\n> index bd62e20268..0d3354d4a8 100644\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -498,6 +498,8 @@ int parse_opt_passthru_argv(const struct option *, const char *, int);\n>  /* value is enum branch_track* */\n>  int parse_opt_tracking_mode(const struct option *, const char *, int);\n>\n> +void parse_opt_skip_end_of_options(int *argc, const char ***argv);\n> +\n>  #define OPT__VERBOSE(var, h)  OPT_COUNTUP('v', \"verbose\", (var), (h))\n>  #define OPT__QUIET(var, h)    OPT_COUNTUP('q', \"quiet\",   (var), (h))\n>  #define OPT__VERBOSITY(var) { \\\n> diff --git a/t/t1090-sparse-checkout-scope.sh b/t/t1090-sparse-checkout-scope.sh\n> index 3a14218b24..5b96716235 100755\n> --- a/t/t1090-sparse-checkout-scope.sh\n> +++ b/t/t1090-sparse-checkout-scope.sh\n> @@ -57,6 +57,14 @@ test_expect_success 'return to full checkout of main' '\n>  test_expect_success 'skip-worktree on files outside sparse patterns' '\n>         git sparse-checkout disable &&\n>         git sparse-checkout set --no-cone \"a*\" &&\n> +       cat .git/info/sparse-checkout >wo-eoo &&\n> +\n> +       git sparse-checkout disable &&\n> +       git sparse-checkout set --no-cone --end-of-options \"a*\" &&\n> +       cat .git/info/sparse-checkout >w-eoo &&\n> +\n> +       test_cmp wo-eoo w-eoo &&\n> +\n>         git checkout-index --all --ignore-skip-worktree-bits &&\n>\n>         git ls-files -t >output &&\n> diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh\n> index f67611da28..e33a6ed1b4 100755\n> --- a/t/t1091-sparse-checkout-builtin.sh\n> +++ b/t/t1091-sparse-checkout-builtin.sh\n> @@ -334,7 +334,7 @@ test_expect_success 'cone mode: set with nested folders' '\n>\n>  test_expect_success 'cone mode: add independent path' '\n>         git -C repo sparse-checkout set deep/deeper1 &&\n> -       git -C repo sparse-checkout add folder1 &&\n> +       git -C repo sparse-checkout add --end-of-options folder1 &&\n>         cat >expect <<-\\EOF &&\n>         /*\n>         !/*/\n> --\n> 2.43.0-174-g055bb6e996\n\nI've got a counter-proposal for this patch at\nhttps://lore.kernel.org/git/pull.1625.git.git.1703379611749.gitgitgadget@gmail.com/,\nbased on further thread discussion over at\nhttps://lore.kernel.org/git/CABPp-BF9XZeESHdxdcZ91Vsn5tKqQ6_3tC11e7t9vTFp=uufbg@mail.gmail.com/.\n"},{"id":"486066","messageId":"xmqq1qb7kwlq.fsf@gitster.g","threadId":"60642","inReplyTo":"CABPp-BF3Vqq8Y8+2pQyO7-StUVPR3as+Q_aL+o92ydoJY-8zEw@mail.gmail.com","subject":"Re: [PATCH 2/3] sparse-checkout: use default patterns for 'set' only !stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-28T00:18:57Z","receivedAt":"2023-12-28T00:19:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n>> diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\n>> index 8f55127202..04ae81fce8 100644\n>> --- a/builtin/sparse-checkout.c\n>> +++ b/builtin/sparse-checkout.c\n>> @@ -837,7 +837,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n>>          * non-cone mode, if nothing is specified, manually select just the\n>>          * top-level directory (much as 'init' would do).\n>>          */\n>> -       if (!core_sparse_checkout_cone && argc == 0) {\n>> +       if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {\n>>                 argv = default_patterns;\n>>                 argc = default_patterns_nr;\n>>         } else {\n>> --\n>> 2.43.0-174-g055bb6e996\n>\n> Thanks for catching this; the fix looks good to me.\n\nActually I am not so sure.\n\nAn obvious alternative would be to collect the patterns, either from\nthe command line or from the standard input, and then use the\ndefault when we collected nothing.\n\nBut I guess those who use the standard input should be able to\nspecify everything fully, so it would probably be OK.\n"}]}