{"thread":{"id":"57195","subject":"Bug report - sparse-checkout ignores prefix when run in subdirectories","startedAt":"2022-01-05T20:13:27Z","lastAt":"2022-01-27T17:30:32Z","messageCount":10,"participants":["Lessley Dennington","Junio C Hamano","Elijah Newren","Derrick Stolee"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"445572","messageId":"29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com","threadId":"57195","inReplyTo":null,"subject":"Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Lessley Dennington","fromEmail":"lessleydennington@gmail.com","sentAt":"2022-01-05T20:13:22Z","receivedAt":"2022-01-05T20:13:27Z","isPatch":false,"sender":{"key":"lessleydennington@gmail.com","avatar":"https://avatars.githubusercontent.com/u/11321782?v=4"},"body":"Hello everyone! See the following bug report pertaining to sparse-checkout\nwhen run outside top-level directories.\n\nThank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n$ git init -b main tmp\n$ cd tmp\n$ mkdir -p a/b/c\n$ touch a/b/c/d a/b/c/e\n$ git add a/\n$ git commit -m \"initial\"\n$ cd a/  # Not at the top level anymore\n$ git sparse-checkout set --cone b/c\n$ git -C .. sparse-checkout list\n\nWhat did you expect to happen? (Expected behavior)\n\nWe expected the output sparsity path to be a/b/c.\n\nWhat happened instead? (Actual behavior)\n\nThe output was b/c. Running $ cat ../.git/info/sparse-checkout\nshowed that the paths in this file were incorrect:\n/*\n!/*/\n/b/\n!/b/*/\n/b/c/\n\nWhat's different between what you expected and what actually happened?\n\nThe output path and the paths in the sparse-checkout file are missing the\nexpected 'a' prefix. This means that the `set` and `add` subcommands of\n`sparse-checkout` can only be safely run from a repo's top-level directory.\n\nAnything else you want to add:\n\nThis was discovered by newren@gmail.com in my recent tab-completion\nseries. You can find additional context at [1].\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n[System Info]\ngit version:\ngit version 2.34.1.88.gcecf501e07.dirty (local build, based off\nen/sparse-checkout-set)\ncpu: x86_64\nshell-path: /bin/zsh\nuname: Darwin\ncompiler info:\nConfigured with: --prefix=/Library/Developer/CommandLineTools/usr\n--with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk\n/usr/include/c++/4.2.1\nApple clang version 13.0.0 (clang-1300.0.29.3)\nTarget: x86_64-apple-darwin20.6.0\nThread model: posix\nInstalledDir: /Library/Developer/CommandLineTools/usr/bin\n$SHELL (typically, interactive shell): /bin/zsh\n\n-Lessley\n\n[1]: \nhttps://lore.kernel.org/git/CABPp-BGdr54XgCXw8k1xRCgkwBtDonyODS3O+_nS_QY3SOEFGQ@mail.gmail.com/\n"},{"id":"445585","messageId":"xmqqsfu1g64s.fsf@gitster.g","threadId":"57195","inReplyTo":"29f0410e-6dfa-2e86-394d-b1fb735e7608@gmail.com","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-05T22:38:43Z","receivedAt":"2022-01-05T22:38:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lessley Dennington <lessleydennington@gmail.com> writes:\n\n> Hello everyone! See the following bug report pertaining to sparse-checkout\n> when run outside top-level directories.\n\nIn a bug report it is fine, but \"outside top-level\" usually means\nabove the top-level of the working tree.  Here, I think you meant\nrunning in a subdirectory of the top-level.\n\nPerhaps something along this line?\n\n builtin/sparse-checkout.c | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git c/builtin/sparse-checkout.c w/builtin/sparse-checkout.c\nindex 45e838d8f8..4e5efbb85e 100644\n--- c/builtin/sparse-checkout.c\n+++ w/builtin/sparse-checkout.c\n@@ -753,6 +753,16 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n \tif (!core_sparse_checkout_cone && argc == 0) {\n \t\targv = default_patterns;\n \t\targc = default_patterns_nr;\n+\t} else if (argc && prefix && *prefix) {\n+\t\t/* \n+\t\t * The args are not pathspecs, so unfortunately we\n+\t\t * cannot imitate how cmd_add() uses parse_pathspec().\n+\t\t */\n+\t\tint i;\n+\t\tint prefix_len = strlen(prefix);\n+\n+\t\tfor (i = 0; i < argc; i++)\n+\t\t\targv[i] = prefix_path(prefix, prefix_len, argv[i]);\n \t}\n \n \treturn modify_pattern_list(argc, argv, set_opts.use_stdin, REPLACE);\n"},{"id":"445591","messageId":"CABPp-BH5woi6KY7OBpnsS-M2EmgLHii9zs8rSwrgcPFkOAvn_A@mail.gmail.com","threadId":"57195","inReplyTo":"xmqqsfu1g64s.fsf@gitster.g","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2022-01-05T23:19:58Z","receivedAt":"2022-01-05T23:20:29Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Jan 5, 2022 at 2:38 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Lessley Dennington <lessleydennington@gmail.com> writes:\n>\n> > Hello everyone! See the following bug report pertaining to sparse-checkout\n> > when run outside top-level directories.\n>\n> In a bug report it is fine, but \"outside top-level\" usually means\n> above the top-level of the working tree.  Here, I think you meant\n> running in a subdirectory of the top-level.\n>\n> Perhaps something along this line?\n>\n>  builtin/sparse-checkout.c | 10 ++++++++++\n>  1 file changed, 10 insertions(+)\n>\n> diff --git c/builtin/sparse-checkout.c w/builtin/sparse-checkout.c\n> index 45e838d8f8..4e5efbb85e 100644\n> --- c/builtin/sparse-checkout.c\n> +++ w/builtin/sparse-checkout.c\n> @@ -753,6 +753,16 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n>         if (!core_sparse_checkout_cone && argc == 0) {\n>                 argv = default_patterns;\n>                 argc = default_patterns_nr;\n> +       } else if (argc && prefix && *prefix) {\n> +               /*\n> +                * The args are not pathspecs, so unfortunately we\n> +                * cannot imitate how cmd_add() uses parse_pathspec().\n> +                */\n> +               int i;\n> +               int prefix_len = strlen(prefix);\n> +\n> +               for (i = 0; i < argc; i++)\n> +                       argv[i] = prefix_path(prefix, prefix_len, argv[i]);\n>         }\n\nThis looks good (sparse_checkout_add() needs a similar fix), at least\nfor cone mode.  There might be a small pickle here that I didn't think\nabout before.  --cone mode always uses directories, so we expect\npeople to provide directory names.  Because of that, I think it's fair\nto expect the arguments passed to `set` or `add` to be paths relative\nto the current working directory.  In contrast, for non-cone mode we\ndo not expect pathnames but gitignore-style globs.  And when we get\ngitignore-style globs, we don't know if they were intended relative to\nthe current working directory or the toplevel, because we only have\none $GIT_DIR/info/sparse-checkout file versus many .gitignore files.\nSo, should \"**.py\" go directly into the sparse-checkout file as-is, or\nbe translated to \"my/current/subdir/**.py\" first?\n\nMaybe translating is always fine, or maybe we want to throw an error\nwhen: (not using cone mode and prefix is non-empty and any patterns\nare provided).\n\nThoughts?\n\n>\n>         return modify_pattern_list(argc, argv, set_opts.use_stdin, REPLACE);\n"},{"id":"445593","messageId":"xmqqbl0pg3s7.fsf@gitster.g","threadId":"57195","inReplyTo":"CABPp-BH5woi6KY7OBpnsS-M2EmgLHii9zs8rSwrgcPFkOAvn_A@mail.gmail.com","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-05T23:29:28Z","receivedAt":"2022-01-05T23:29:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n> So, should \"**.py\" go directly into the sparse-checkout file as-is, or\n> be translated to \"my/current/subdir/**.py\" first?\n>\n> Maybe translating is always fine, or maybe we want to throw an error\n> when: (not using cone mode and prefix is non-empty and any patterns\n> are provided).\n>\n> Thoughts?\n\nPerhaps allow things like \":(glob,icase,top)frotz\" to be passed and\ntreating them as pathspec is the most sensible way to go outside the\ncone mode?  As far as I understand, the cone mode is a strict subset\nthat is straight-jacketed into \"no patterns allowed, just concrete\ndirectory names and nothing else\" for simplicity, so it is perfectly\nOK for these two to be taking different things.\n"},{"id":"445598","messageId":"CABPp-BFfuDMQXCZg_5YXQLaPtc9nyrJaq8J6VEDVsaiEMeeZMA@mail.gmail.com","threadId":"57195","inReplyTo":"xmqqbl0pg3s7.fsf@gitster.g","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2022-01-06T00:08:42Z","receivedAt":"2022-01-06T00:10:20Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Jan 5, 2022 at 3:29 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Elijah Newren <newren@gmail.com> writes:\n>\n> > So, should \"**.py\" go directly into the sparse-checkout file as-is, or\n> > be translated to \"my/current/subdir/**.py\" first?\n> >\n> > Maybe translating is always fine, or maybe we want to throw an error\n> > when: (not using cone mode and prefix is non-empty and any patterns\n> > are provided).\n> >\n> > Thoughts?\n>\n> Perhaps allow things like \":(glob,icase,top)frotz\" to be passed and\n> treating them as pathspec is the most sensible way to go outside the\n> cone mode?  As far as I understand, the cone mode is a strict subset\n> that is straight-jacketed into \"no patterns allowed, just concrete\n> directory names and nothing else\" for simplicity, so it is perfectly\n> OK for these two to be taking different things.\n\nAre you possibly confusing pathspecs with gitignore patterns here?\n(Or am I?)  Or are you suggesting that sparse-checkout be modified to\naccept either gitignore-style files or pathspecs and handle both?\n\nI have never liked that gitignore-style patterns were used for\nsparse-checkout, but it has always seemed a bit too late to change it.\nEver since Stolee introduced cone-mode, my preferred strategy for\nfixing the gitignore-style patterns problem, assuming we are allowed\nto do so, is to deprecate if not kill non-cone mode.  (And in the\nmeantime, I'm just doing due diligence when I mention non-cone mode in\nmy reviews.)\n"},{"id":"445599","messageId":"xmqq7dbdg1k6.fsf@gitster.g","threadId":"57195","inReplyTo":"CABPp-BFfuDMQXCZg_5YXQLaPtc9nyrJaq8J6VEDVsaiEMeeZMA@mail.gmail.com","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-06T00:17:29Z","receivedAt":"2022-01-06T00:17:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n> Are you possibly confusing pathspecs with gitignore patterns here?\n> (Or am I?)  Or are you suggesting that sparse-checkout be modified to\n> accept either gitignore-style files or pathspecs and handle both?\n\nMuch closer to the latter (actually, removing ignore patterns, and\nmake the subsystem work with pathspecs).\n\n> I have never liked that gitignore-style patterns were used for\n> sparse-checkout, but it has always seemed a bit too late to change it.\n\nPerhaps.\n\n> Ever since Stolee introduced cone-mode, my preferred strategy for\n> fixing the gitignore-style patterns problem, assuming we are allowed\n> to do so, is to deprecate if not kill non-cone mode.  (And in the\n> meantime, I'm just doing due diligence when I mention non-cone mode in\n> my reviews.)\n"},{"id":"445602","messageId":"CABPp-BF=-1aZd=nFHF6spo7Ksa7f7Wb7ervCt0QvtNitMY=ZBA@mail.gmail.com","threadId":"57195","inReplyTo":"xmqq7dbdg1k6.fsf@gitster.g","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2022-01-06T01:08:43Z","receivedAt":"2022-01-06T01:08:59Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Wed, Jan 5, 2022 at 4:17 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Elijah Newren <newren@gmail.com> writes:\n>\n> > Are you possibly confusing pathspecs with gitignore patterns here?\n> > (Or am I?)  Or are you suggesting that sparse-checkout be modified to\n> > accept either gitignore-style files or pathspecs and handle both?\n>\n> Much closer to the latter (actually, removing ignore patterns, and\n> make the subsystem work with pathspecs).\n\nOh, interesting.  That'd at least suggest you're also happy to get rid\nof the ignore patterns in this subsystem if we find a feasible\ntransition plan to do so.  I'll keep that in mind.  :-)\n\n> > I have never liked that gitignore-style patterns were used for\n> > sparse-checkout, but it has always seemed a bit too late to change it.\n>\n> Perhaps.\n>\n> > Ever since Stolee introduced cone-mode, my preferred strategy for\n> > fixing the gitignore-style patterns problem, assuming we are allowed\n> > to do so, is to deprecate if not kill non-cone mode.  (And in the\n> > meantime, I'm just doing due diligence when I mention non-cone mode in\n> > my reviews.)\n"},{"id":"445643","messageId":"xmqqy23sd5v6.fsf@gitster.g","threadId":"57195","inReplyTo":"CABPp-BF=-1aZd=nFHF6spo7Ksa7f7Wb7ervCt0QvtNitMY=ZBA@mail.gmail.com","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-06T19:25:01Z","receivedAt":"2022-01-06T19:25:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n> On Wed, Jan 5, 2022 at 4:17 PM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Elijah Newren <newren@gmail.com> writes:\n>>\n>> > Are you possibly confusing pathspecs with gitignore patterns here?\n>> > (Or am I?)  Or are you suggesting that sparse-checkout be modified to\n>> > accept either gitignore-style files or pathspecs and handle both?\n>>\n>> Much closer to the latter (actually, removing ignore patterns, and\n>> make the subsystem work with pathspecs).\n>\n> Oh, interesting.  That'd at least suggest you're also happy to get rid\n> of the ignore patterns in this subsystem if we find a feasible\n> transition plan to do so.  I'll keep that in mind.  :-)\n\nIt is more like \"I've never used it and I'll probably never use it\nmyself, so I have no data as to how badly we will be hurting\nexisting users\".\n"},{"id":"447098","messageId":"e1934710-e228-adc4-d37c-f706883bd27c@gmail.com","threadId":"57195","inReplyTo":"CABPp-BH5woi6KY7OBpnsS-M2EmgLHii9zs8rSwrgcPFkOAvn_A@mail.gmail.com","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2022-01-27T16:43:08Z","receivedAt":"2022-01-27T16:43:12Z","isPatch":false,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 1/5/2022 6:19 PM, Elijah Newren wrote:\n> On Wed, Jan 5, 2022 at 2:38 PM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Lessley Dennington <lessleydennington@gmail.com> writes:\n>>\n>>> Hello everyone! See the following bug report pertaining to sparse-checkout\n>>> when run outside top-level directories.\n>>\n>> In a bug report it is fine, but \"outside top-level\" usually means\n>> above the top-level of the working tree.  Here, I think you meant\n>> running in a subdirectory of the top-level.\n>>\n>> Perhaps something along this line?\n>>\n>>  builtin/sparse-checkout.c | 10 ++++++++++\n>>  1 file changed, 10 insertions(+)\n>>\n>> diff --git c/builtin/sparse-checkout.c w/builtin/sparse-checkout.c\n>> index 45e838d8f8..4e5efbb85e 100644\n>> --- c/builtin/sparse-checkout.c\n>> +++ w/builtin/sparse-checkout.c\n>> @@ -753,6 +753,16 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n>>         if (!core_sparse_checkout_cone && argc == 0) {\n>>                 argv = default_patterns;\n>>                 argc = default_patterns_nr;\n>> +       } else if (argc && prefix && *prefix) {\n>> +               /*\n>> +                * The args are not pathspecs, so unfortunately we\n>> +                * cannot imitate how cmd_add() uses parse_pathspec().\n>> +                */\n>> +               int i;\n>> +               int prefix_len = strlen(prefix);\n>> +\n>> +               for (i = 0; i < argc; i++)\n>> +                       argv[i] = prefix_path(prefix, prefix_len, argv[i]);\n>>         }\n> \n> This looks good (sparse_checkout_add() needs a similar fix), at least\n> for cone mode.  There might be a small pickle here that I didn't think\n> about before.  --cone mode always uses directories, so we expect\n> people to provide directory names.  Because of that, I think it's fair\n> to expect the arguments passed to `set` or `add` to be paths relative\n> to the current working directory.  In contrast, for non-cone mode we\n> do not expect pathnames but gitignore-style globs.  And when we get\n> gitignore-style globs, we don't know if they were intended relative to\n> the current working directory or the toplevel, because we only have\n> one $GIT_DIR/info/sparse-checkout file versus many .gitignore files.\n> So, should \"**.py\" go directly into the sparse-checkout file as-is, or\n> be translated to \"my/current/subdir/**.py\" first?\n> \n> Maybe translating is always fine, or maybe we want to throw an error\n> when: (not using cone mode and prefix is non-empty and any patterns\n> are provided).\n> \n> Thoughts?\n\nYou seem to have worked it out in the other threads, but I came here\nto agree: we should not do this transformation unless we are in\ncone mode. We should also do this when \"--cone\" is supplied.\n\nThe prefix_path() collapses \"../\" entries, right? Just making sure\nthat we test that scenario when writing a full fix here.\n\nFor example, if we added a case to t1092, we should be able to\ndo the following within any of the example repos:\n\n\tgit sparse-checkout disable &&\n\tcd folder1 &&\n\tgit sparse-checkout set --cone . ../folder2\n\tgit sparse-checkout list >actual &&\n\tcat >expect <<-EOF &&\n\tfolder1\n\tfolder2\n\tEOF\n\ttest_cmp expect actual\n\nThanks,\n-Stolee\n"},{"id":"447101","messageId":"CABPp-BEr4=AgGzV_+voJZO8EHkMkpXRHM-LJuzVciKoNE1Dc5w@mail.gmail.com","threadId":"57195","inReplyTo":"e1934710-e228-adc4-d37c-f706883bd27c@gmail.com","subject":"Re: Bug report - sparse-checkout ignores prefix when run in subdirectories","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2022-01-27T17:30:15Z","receivedAt":"2022-01-27T17:30:32Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Thu, Jan 27, 2022 at 8:43 AM Derrick Stolee <stolee@gmail.com> wrote:\n>\n> On 1/5/2022 6:19 PM, Elijah Newren wrote:\n> > On Wed, Jan 5, 2022 at 2:38 PM Junio C Hamano <gitster@pobox.com> wrote:\n> >>\n> >> Lessley Dennington <lessleydennington@gmail.com> writes:\n> >>\n> >>> Hello everyone! See the following bug report pertaining to sparse-checkout\n> >>> when run outside top-level directories.\n> >>\n> >> In a bug report it is fine, but \"outside top-level\" usually means\n> >> above the top-level of the working tree.  Here, I think you meant\n> >> running in a subdirectory of the top-level.\n> >>\n> >> Perhaps something along this line?\n> >>\n> >>  builtin/sparse-checkout.c | 10 ++++++++++\n> >>  1 file changed, 10 insertions(+)\n> >>\n> >> diff --git c/builtin/sparse-checkout.c w/builtin/sparse-checkout.c\n> >> index 45e838d8f8..4e5efbb85e 100644\n> >> --- c/builtin/sparse-checkout.c\n> >> +++ w/builtin/sparse-checkout.c\n> >> @@ -753,6 +753,16 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)\n> >>         if (!core_sparse_checkout_cone && argc == 0) {\n> >>                 argv = default_patterns;\n> >>                 argc = default_patterns_nr;\n> >> +       } else if (argc && prefix && *prefix) {\n> >> +               /*\n> >> +                * The args are not pathspecs, so unfortunately we\n> >> +                * cannot imitate how cmd_add() uses parse_pathspec().\n> >> +                */\n> >> +               int i;\n> >> +               int prefix_len = strlen(prefix);\n> >> +\n> >> +               for (i = 0; i < argc; i++)\n> >> +                       argv[i] = prefix_path(prefix, prefix_len, argv[i]);\n> >>         }\n> >\n> > This looks good (sparse_checkout_add() needs a similar fix), at least\n> > for cone mode.  There might be a small pickle here that I didn't think\n> > about before.  --cone mode always uses directories, so we expect\n> > people to provide directory names.  Because of that, I think it's fair\n> > to expect the arguments passed to `set` or `add` to be paths relative\n> > to the current working directory.  In contrast, for non-cone mode we\n> > do not expect pathnames but gitignore-style globs.  And when we get\n> > gitignore-style globs, we don't know if they were intended relative to\n> > the current working directory or the toplevel, because we only have\n> > one $GIT_DIR/info/sparse-checkout file versus many .gitignore files.\n> > So, should \"**.py\" go directly into the sparse-checkout file as-is, or\n> > be translated to \"my/current/subdir/**.py\" first?\n> >\n> > Maybe translating is always fine, or maybe we want to throw an error\n> > when: (not using cone mode and prefix is non-empty and any patterns\n> > are provided).\n> >\n> > Thoughts?\n>\n> You seem to have worked it out in the other threads, but I came here\n> to agree: we should not do this transformation unless we are in\n> cone mode. We should also do this when \"--cone\" is supplied.\n\nActually, I didn't figure it out.  See also the last four paragraphs\nof https://lore.kernel.org/git/CABPp-BEwMAPHGt5xD9jDU58grbrAqCdqNY9Nh8UJGLKuLbArXQ@mail.gmail.com/\nfor related confounding factors.\n\nAnyway, Junio's insistence elsewhere (earlier in the above linked\nthread) that bash-completion include both files and directories in\nnon-cone mode seemed to only make sense if we did this transformation\nin non-cone mode.  So, I implemented the transformation for both\nmodes, though I called out how it causes some possibly nasty surprises\nin non-cone mode.  It's not yet submitted (wanted other series to\nmerge to next first), but you can see it at\nhttps://github.com/gitgitgadget/git/pull/1118; it's the commit\nentitled, \"Pay attention to prefix for {set, add}\".  The final patch\nin that series also adds a \"NON-CONE PROBLEMS\" section to the manual\ndetailing six different problems with non-cone mode (all of which are\nfundamental and unfixable), one of which is this one.  The fourth\npatch also possibly mixes in with this topic.\n\nAnyway, whether or not there is a clean answer here, that other series\nat least carefully points out how non-cone mode is fundamentally\nproblematic and deprecates it.\n\n> The prefix_path() collapses \"../\" entries, right? Just making sure\n> that we test that scenario when writing a full fix here.\n>\n> For example, if we added a case to t1092, we should be able to\n> do the following within any of the example repos:\n>\n>         git sparse-checkout disable &&\n>         cd folder1 &&\n>         git sparse-checkout set --cone . ../folder2\n>         git sparse-checkout list >actual &&\n>         cat >expect <<-EOF &&\n>         folder1\n>         folder2\n>         EOF\n>         test_cmp expect actual\n\nYes, \"../\" is handled; I added testcases to t1091 to verify that; they\nlook pretty much exactly like what you suggest here, so we seem to be\non the same wavelength.\n"}]}