{"thread":{"id":"60379","subject":"Bug: dir.c traversing the filesystem: unindexed directories do not get recursed into when there is a (non-excluding) pathspec","startedAt":"2023-10-17T00:08:45Z","lastAt":"2023-10-17T00:08:45Z","messageCount":1,"participants":["Joanna Wang"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"483326","messageId":"CAMmZTi89Un+bsLXdEdYs44oT8eLNp8y=Pm8ywaurcQ7ccRKGdQ@mail.gmail.com","threadId":"60379","inReplyTo":null,"subject":"Bug: dir.c traversing the filesystem: unindexed directories do not get recursed into when there is a (non-excluding) pathspec","fromName":"Joanna Wang","fromEmail":"jojwang@google.com","sentAt":"2023-10-17T00:08:30Z","receivedAt":"2023-10-17T00:08:45Z","isPatch":false,"sender":{"key":"jojwang@google.com","avatar":"https://avatars.githubusercontent.com/u/120585822?v=4"},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\nI created a new untracked directory `foo/`.\nIn .gitattributes i added `bar_yes* text`\nand created files `foo/bar_yes` and `foo/bar_no` with content 'chicken'\n\nI tried the following commands:\ngit grep --no-index chicken -- ':(attr:text)foo/*'\ngit ls-files --others --exclude-standard ':(attr:text)foo/*'\ngit status ':(attr:text)foo/*'\n\n\nWhat did you expect to happen? (Expected behavior)\nFor all of the above, I expected `foo/bar_yes` to be returned.\n\nWhat happened instead? (Actual behavior)\nFor all three commands, nothing was returned.\n\nAnything else you want to add:\nIf I change the pathspec to ':(exclude,attr:text)foo/*' it works as expected.\n`foo/bar_no` is returned.\n\n(except for git status where the output is just `foo/`, but I think\nthis is expected.)\n\nThis behavior seems due to this section in dir.c:\nhttps://github.com/git/git/blob/master/dir.c#L1893-L1908\nfor a pathspec like ':(attr:text)foo/*', this section of code will prevent\n`foo/` from getting recursed.\nIt only checks for a pathspec match against the directory name, so any\nfiles under the dir aren't checked.\nCommenting that part of the code out, seems to fix this issue.\n(for `git status`, `foo/` is returned both with `exclude` in the\npathspec and without)\nBut I am not sure if simply removing that code is the right fix.\n\n[Enabled Hooks]\ncommit-msg\npre-commit\nprepare-commit-msg\n"}]}