{"thread":{"id":"45692","subject":"[BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories","startedAt":"2017-04-14T19:17:44Z","lastAt":"2017-04-16T18:45:43Z","messageCount":5,"participants":["Alistair Buxton","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"316840","messageId":"CAO-Op+GujOUuueqwOKbb1NosZ-VYY5KVWm1+HNMC8xhd0ApEDw@mail.gmail.com","threadId":"45692","inReplyTo":null,"subject":"[BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories","fromName":"Alistair Buxton","fromEmail":"a.j.buxton@gmail.com","sentAt":"2017-04-14T19:17:37Z","receivedAt":"2017-04-14T19:17:44Z","isPatch":false,"sender":{"key":"a.j.buxton@gmail.com","avatar":null},"body":"To reproduce, go to any git repository and run:\n\n    diff <(git ls-files '**/*' | sort) <(git ls-files | sort)\n\nExpected result: No output since both commands should produce identical output.\n\nActual result: '**/*' only matches files at least one directory deep.\n\nThe same happens with eg '**/Makefile' - only Makefiles in\nsubdirectories are listed.\n\nI have personally tested with 2.7.8 and 2.12.0. Others on IRC report\nthat this happens in the next branch.\n\n-- \nAlistair Buxton\na.j.buxton@gmail.com\n"},{"id":"316944","messageId":"CACsJy8ASuQqnZb97BmPtOeAoTuS4bE6-7p21SDd9DP6SNyX+3Q@mail.gmail.com","threadId":"45692","inReplyTo":"CAO-Op+GujOUuueqwOKbb1NosZ-VYY5KVWm1+HNMC8xhd0ApEDw@mail.gmail.com","subject":"Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-04-16T10:53:03Z","receivedAt":"2017-04-16T11:16:54Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Apr 15, 2017 at 2:17 AM, Alistair Buxton <a.j.buxton@gmail.com> wrote:\n> To reproduce, go to any git repository and run:\n>\n>     diff <(git ls-files '**/*' | sort) <(git ls-files | sort)\n>\n> Expected result: No output since both commands should produce identical output.\n>\n> Actual result: '**/*' only matches files at least one directory deep.\n>\n> The same happens with eg '**/Makefile' - only Makefiles in\n> subdirectories are listed.\n>\n> I have personally tested with 2.7.8 and 2.12.0. Others on IRC report\n> that this happens in the next branch.\n\nAnother data point. t3070-wildmatch.sh has a test for this case\n\nmatch 1 0 'foo' '**/foo'\n\nso the pattern matching machinery is _not_ broken. There may be some\nchanges in ls-files (pathspec-related?) that leads to this. But I\ndidn't try to bisect it.\n-- \nDuy\n"},{"id":"316945","messageId":"CACsJy8DQWrLZF3wUQ5WF2FfriM6ko8Zwm_x5ErEEWTE6n5rayw@mail.gmail.com","threadId":"45692","inReplyTo":"CAO-Op+GujOUuueqwOKbb1NosZ-VYY5KVWm1+HNMC8xhd0ApEDw@mail.gmail.com","subject":"Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-04-16T11:25:47Z","receivedAt":"2017-04-16T11:26:23Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Apr 15, 2017 at 2:17 AM, Alistair Buxton <a.j.buxton@gmail.com> wrote:\n> To reproduce, go to any git repository and run:\n>\n>     diff <(git ls-files '**/*' | sort) <(git ls-files | sort)\n\nActually the '**/' magic only kicks in if you write\n\ngit ls-files ':(glob)**/*'\n\nWithout that '**' is a normal '*' and matching just subdirs is expected.\n-- \nDuy\n"},{"id":"316950","messageId":"CAO-Op+Fd9x7O66skWWy5TkTfMst7ohUiw3U9MMujyvYsjWnFSg@mail.gmail.com","threadId":"45692","inReplyTo":"CACsJy8DQWrLZF3wUQ5WF2FfriM6ko8Zwm_x5ErEEWTE6n5rayw@mail.gmail.com","subject":"Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories","fromName":"Alistair Buxton","fromEmail":"a.j.buxton@gmail.com","sentAt":"2017-04-16T16:29:36Z","receivedAt":"2017-04-16T16:29:43Z","isPatch":false,"sender":{"key":"a.j.buxton@gmail.com","avatar":null},"body":"On 16 April 2017 at 12:25, Duy Nguyen <pclouds@gmail.com> wrote:\n> git ls-files ':(glob)**/*'\n>\n> Without that '**' is a normal '*' and matching just subdirs is expected.\n\n\nBut '*/' should match exactly one subdirectory deep. Instead it\nmatches one more more subdirectories.\n\nMeaning it behaves the way '**/*/' should.\n\nTry the following in the git source repo:\n\n    shopt -s globstar\n    diff <(ls -1 */.gitignore | sort) <(git ls-files '*/.gitignore' | sort)\n    diff <(ls -1 */**/.gitignore | sort) <(git ls-files '*/.gitignore' | sort)\n\nof course it works as expected if you say the magic word:\n\n    diff <(ls -1 */.gitignore | sort) <(git ls-files\n':(glob)*/.gitignore' | sort)\n\n\n-- \nAlistair Buxton\na.j.buxton@gmail.com\n"},{"id":"316955","messageId":"CAO-Op+HTNdn6gE_V-4dBjjYTfSjq71sXhBVV6vutFzm2fsctQQ@mail.gmail.com","threadId":"45692","inReplyTo":"CAO-Op+Fd9x7O66skWWy5TkTfMst7ohUiw3U9MMujyvYsjWnFSg@mail.gmail.com","subject":"Re: [BUG] ls-files '**' globstar matches one or more directories instead of zero or more directories","fromName":"Alistair Buxton","fromEmail":"a.j.buxton@gmail.com","sentAt":"2017-04-16T18:45:36Z","receivedAt":"2017-04-16T18:45:43Z","isPatch":false,"sender":{"key":"a.j.buxton@gmail.com","avatar":null},"body":"On IRC someone pointed me to the glossary section for pathspec, and I\nfind that even more confusing.\n\nIn the section about \":(glob)\" it says:\n\n> For example, \"**/foo\" matches file or directory \"foo\" anywhere, the same as pattern \"foo\".\n\nThis is not true for ls-files: \":(glob)**/.gitignore\" is completely\ndifferent to \":(glob).gitignore\".\n\nThe only place where it is true is inside .gitignore files, and there\nthe \":(glob)\" syntax does not work.\n\n\n-- \nAlistair Buxton\na.j.buxton@gmail.com\n"}]}