{"thread":{"id":"56876","subject":"bug report","startedAt":"2021-11-12T04:22:49Z","lastAt":"2021-11-12T14:27:24Z","messageCount":4,"participants":["Theodore Li","Junio C Hamano","Paul Smith"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"440954","messageId":"CAHPjYFyzPpUmfoCbvaVg25ZbhkHU8QtxHBmAh2gdT++Xr38HcQ@mail.gmail.com","threadId":"56876","inReplyTo":null,"subject":"bug report","fromName":"Theodore Li","fromEmail":"teddy.litheodore@gmail.com","sentAt":"2021-11-12T04:22:32Z","receivedAt":"2021-11-12T04:22:49Z","isPatch":false,"sender":{"key":"teddy.litheodore@gmail.com","avatar":null},"body":"Thank 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)\nAfter cloning a remote repository with the --no-checkout option and\nexecuting git sparse-checkout init, the bug occurs with any\nsparse-checkout command with the /* pattern (i.e. git sparse-checkout\nset /*).\n\nWhat did you expect to happen? (Expected behavior)\nThe contents of .git/info/sparse-checkout and the output of git\nsparse-checkout list should be '/*'\n\nWhat happened instead? (Actual behavior)\nInstead, the output is the contents of the user's local root directory\n(i.e. /bin, /boot, /cdrom, etc.).\n\nWhat's different between what you expected and what actually happened?\nIt should set sparse-checkout to the pattern /*, corresponding to the\nremote repository's root directory instead of adding all the folders\nand files in the root directory of the user's local machine.\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.33.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\ncompiler info: gnuc: 9.3\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n"},{"id":"440955","messageId":"xmqq8rxuj8s8.fsf@gitster.g","threadId":"56876","inReplyTo":"CAHPjYFyzPpUmfoCbvaVg25ZbhkHU8QtxHBmAh2gdT++Xr38HcQ@mail.gmail.com","subject":"Re: bug report","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-11-12T04:29:59Z","receivedAt":"2021-11-12T04:30:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Theodore Li <teddy.litheodore@gmail.com> writes:\n\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> After cloning a remote repository with the --no-checkout option and\n> executing git sparse-checkout init, the bug occurs with any\n> sparse-checkout command with the /* pattern (i.e. git sparse-checkout\n> set /*).\n>\n> What did you expect to happen? (Expected behavior)\n> The contents of .git/info/sparse-checkout and the output of git\n> sparse-checkout list should be '/*'\n>\n> What happened instead? (Actual behavior)\n> Instead, the output is the contents of the user's local root directory\n> (i.e. /bin, /boot, /cdrom, etc.).\n\nA blind guess, as I do not use sparse patterns, but perhaps you did\nnot quote the \"/*' pattern, i.e. you typed\n\n    $ git sparse-checkout set /*\n\nwhere you would have got a better behaviour if you typed\n\n    $ git sparse-checkout set \"/*\"\n\n?\n"},{"id":"440969","messageId":"CAHPjYFyH+GuBG8QNzD36JhoJWyNnEXfqpn4PUJV0ANF2ertYZg@mail.gmail.com","threadId":"56876","inReplyTo":"xmqq8rxuj8s8.fsf@gitster.g","subject":"Re: bug report","fromName":"Theodore Li","fromEmail":"teddy.litheodore@gmail.com","sentAt":"2021-11-12T06:59:49Z","receivedAt":"2021-11-12T07:00:03Z","isPatch":false,"sender":{"key":"teddy.litheodore@gmail.com","avatar":null},"body":"Yes, though other patterns like !/*/ don't need the quotes. I thought\nit worked the same way without the quotes in earlier versions, but\nafter testing with version 2.32.0, it seems like the behavior is the\nsame. Guess I remembered wrong.\n\nOn Thu, Nov 11, 2021 at 11:30 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Theodore Li <teddy.litheodore@gmail.com> writes:\n>\n> > Thank you for filling out a Git bug report!\n> > Please answer the following questions to help us understand your issue.\n> >\n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> > After cloning a remote repository with the --no-checkout option and\n> > executing git sparse-checkout init, the bug occurs with any\n> > sparse-checkout command with the /* pattern (i.e. git sparse-checkout\n> > set /*).\n> >\n> > What did you expect to happen? (Expected behavior)\n> > The contents of .git/info/sparse-checkout and the output of git\n> > sparse-checkout list should be '/*'\n> >\n> > What happened instead? (Actual behavior)\n> > Instead, the output is the contents of the user's local root directory\n> > (i.e. /bin, /boot, /cdrom, etc.).\n>\n> A blind guess, as I do not use sparse patterns, but perhaps you did\n> not quote the \"/*' pattern, i.e. you typed\n>\n>     $ git sparse-checkout set /*\n>\n> where you would have got a better behaviour if you typed\n>\n>     $ git sparse-checkout set \"/*\"\n>\n> ?\n"},{"id":"440982","messageId":"fd7946fac4e1e43b8fd9dbeb8cab22d83d7094a8.camel@mad-scientist.net","threadId":"56876","inReplyTo":"CAHPjYFyH+GuBG8QNzD36JhoJWyNnEXfqpn4PUJV0ANF2ertYZg@mail.gmail.com","subject":"Re: bug report","fromName":"Paul Smith","fromEmail":"paul@mad-scientist.net","sentAt":"2021-11-12T14:05:56Z","receivedAt":"2021-11-12T14:27:24Z","isPatch":false,"sender":{"key":"paul@mad-scientist.net","avatar":"https://avatars.githubusercontent.com/u/109636?v=4"},"body":"On Fri, 2021-11-12 at 01:59 -0500, Theodore Li wrote:\n> Yes, though other patterns like !/*/ don't need the quotes. I thought\n> it worked the same way without the quotes in earlier versions, but\n> after testing with version 2.32.0, it seems like the behavior is the\n> same. Guess I remembered wrong.\n\nIt's important to realize that in a POSIX-style shell (as you'll find\non GNU/Linux or MacOS, or in the Git for Windows shell), wildcard\nexpansion is performed _by the shell_ before the program is even\ninvoked.  It's not performed by the program itself (in this case, Git).\n\nIn a POSIX-style shell it works like this (by default): first the shell\nwill try to expand the wildcards in your command line by matching them\nfor files.  If any match, the wildcard expression is replaced on the\ncommand line.  If no files match, then the wildcard expression is\npassed to the command without change.\n\nSo if you run:\n\n  git sparse-checkout /*\n\nthen the shell will check if any files match the wildcard /*: since\nclearly you will get matches for this expression, they will be expanded\nand the shell will actually run:\n\n  git sparse-checkout /bin /boot /cdrom /dev /...\n\nNote, Git does not receive any indication that there ever was a\nwildcard expression here!\n\nOn the other hand if you run:\n\n  git sparse-checkout /blah/*/blah\n\n(assuming you don't have any files on your system that match this\nwildcard) then it won't match and the shell will run:\n\n  git sparse-checkout /blah/*/blah\n\nNow Git can examine this wildcard and do an appropriate thing with it.\n\nIn short, if you want to be _sure_ that a wildcard expression is passed\nto the command and not expanded by the shell, you must always quote it:\n\n  git sparse-checkout \"/*\"\n\nIf you don't quote it then it may or may not do what you intended,\ndepending on whether the wildcard happens to match any files.\n\n"}]}