{"thread":{"id":"65298","subject":"git grep failure?","startedAt":"2026-03-18T23:28:18Z","lastAt":"2026-03-19T17:24:03Z","messageCount":7,"participants":["Randy Dunlap","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"539336","messageId":"7bbcda60-dad4-41d4-b994-c19f83f37e2f@infradead.org","threadId":"65298","inReplyTo":null,"subject":"git grep failure?","fromName":"Randy Dunlap","fromEmail":"rdunlap@infradead.org","sentAt":"2026-03-18T23:28:17Z","receivedAt":"2026-03-18T23:28:18Z","isPatch":false,"sender":{"key":"rdunlap@infradead.org","avatar":null},"body":"Hi,\n\nIf I apply the patch at\nhttps://lore.kernel.org/linux-doc/c5bb61cf789df1ecb32facc29df9749987c7ddfc.1773346620.git.ljs@kernel.org/\n\nSubject: [PATCH 02/15] mm: add documentation for the mmap_prepare file operation callback\n\nto the Linux kernel tree (e.g., linux-next-20260316), it applies cleanly.\n\nI noticed a typo in the patch (\"struct vma_area_desc\" should be\n\"struct vm_area_desc\"). When I run\n$ git grep vma_area_desc\nthe output is empty.\n\nIs this expected? (but not by me :)\n\nthanks.\n-- \n~Randy\n\n"},{"id":"539337","messageId":"20260319003829.GA3530301@coredump.intra.peff.net","threadId":"65298","inReplyTo":"7bbcda60-dad4-41d4-b994-c19f83f37e2f@infradead.org","subject":"Re: git grep failure?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-03-19T00:38:29Z","receivedAt":"2026-03-19T00:38:36Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 18, 2026 at 04:28:17PM -0700, Randy Dunlap wrote:\n\n> If I apply the patch at\n> https://lore.kernel.org/linux-doc/c5bb61cf789df1ecb32facc29df9749987c7ddfc.1773346620.git.ljs@kernel.org/\n> \n> Subject: [PATCH 02/15] mm: add documentation for the mmap_prepare file operation callback\n> \n> to the Linux kernel tree (e.g., linux-next-20260316), it applies cleanly.\n> \n> I noticed a typo in the patch (\"struct vma_area_desc\" should be\n> \"struct vm_area_desc\"). When I run\n> $ git grep vma_area_desc\n> the output is empty.\n> \n> Is this expected? (but not by me :)\n\nI applied the patch and git-grep does produce one line of output (the\ninstance added by the patch).\n\nTwo possible differences:\n\n  - are you sure the patch application succeeded?\n\n  - are you in a different subdirectory? By default git-grep narrows its\n    search to your current working directory and its subdirectories. So\n    if you are in arch/ or something, it would not find the result in\n    Documentation/. You can do:\n\n      git grep vma_area_desc :/\n\n    to search from the root of the project.\n\n-Peff\n"},{"id":"539339","messageId":"2c943182-d5d7-4f72-ab97-8d07bf4ed216@infradead.org","threadId":"65298","inReplyTo":"20260319003829.GA3530301@coredump.intra.peff.net","subject":"Re: git grep failure?","fromName":"Randy Dunlap","fromEmail":"rdunlap@infradead.org","sentAt":"2026-03-19T04:42:23Z","receivedAt":"2026-03-19T04:42:24Z","isPatch":false,"sender":{"key":"rdunlap@infradead.org","avatar":null},"body":"\n\nOn 3/18/26 5:38 PM, Jeff King wrote:\n> On Wed, Mar 18, 2026 at 04:28:17PM -0700, Randy Dunlap wrote:\n> \n>> If I apply the patch at\n>> https://lore.kernel.org/linux-doc/c5bb61cf789df1ecb32facc29df9749987c7ddfc.1773346620.git.ljs@kernel.org/\n>>\n>> Subject: [PATCH 02/15] mm: add documentation for the mmap_prepare file operation callback\n>>\n>> to the Linux kernel tree (e.g., linux-next-20260316), it applies cleanly.\n>>\n>> I noticed a typo in the patch (\"struct vma_area_desc\" should be\n>> \"struct vm_area_desc\"). When I run\n>> $ git grep vma_area_desc\n>> the output is empty.\n>>\n>> Is this expected? (but not by me :)\n> \n> I applied the patch and git-grep does produce one line of output (the\n> instance added by the patch).\n> \n> Two possible differences:\n> \n>   - are you sure the patch application succeeded?\n\n'git apply filename.patch' succeeded AFAICT. git status shows one\nuntracked file (the one that is added by the patch).\nDo I need to do 'git commit' also?\n\n>   - are you in a different subdirectory? By default git-grep narrows its\n>     search to your current working directory and its subdirectories. So\n>     if you are in arch/ or something, it would not find the result in\n>     Documentation/. You can do:\n> \n>       git grep vma_area_desc :/\n> \n>     to search from the root of the project.\n\nI'm running 'git grep' from the top-level directory of the\nkernel source tree.\n\nthanks.\n-- \n~Randy\n\n"},{"id":"539340","messageId":"xmqq7br8o0uf.fsf@gitster.g","threadId":"65298","inReplyTo":"2c943182-d5d7-4f72-ab97-8d07bf4ed216@infradead.org","subject":"Re: git grep failure?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-19T05:16:40Z","receivedAt":"2026-03-19T05:16:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Randy Dunlap <rdunlap@infradead.org> writes:\n\n> On 3/18/26 5:38 PM, Jeff King wrote:\n>> On Wed, Mar 18, 2026 at 04:28:17PM -0700, Randy Dunlap wrote:\n>> \n>>> If I apply the patch at\n>>> https://lore.kernel.org/linux-doc/c5bb61cf789df1ecb32facc29df9749987c7ddfc.1773346620.git.ljs@kernel.org/\n>>>\n>>> Subject: [PATCH 02/15] mm: add documentation for the mmap_prepare file operation callback\n>>>\n>>> to the Linux kernel tree (e.g., linux-next-20260316), it applies cleanly.\n>>>\n>>> I noticed a typo in the patch (\"struct vma_area_desc\" should be\n>>> \"struct vm_area_desc\"). When I run\n>>> $ git grep vma_area_desc\n>>> the output is empty.\n>>>\n>>> Is this expected? (but not by me :)\n>> \n>> I applied the patch and git-grep does produce one line of output (the\n>> instance added by the patch).\n>> \n>> Two possible differences:\n>> \n>>   - are you sure the patch application succeeded?\n>\n> 'git apply filename.patch' succeeded AFAICT. git status shows one\n> untracked file (the one that is added by the patch).\n> Do I need to do 'git commit' also?\n\n\"git apply filename.patch\" or \"git apply --index filename.patch\"?\nThe former will leave the new file unknown to \"git\", so \"git grep\"\nwould not look into it.\n\n>>   - are you in a different subdirectory? By default git-grep narrows its\n>>     search to your current working directory and its subdirectories. So\n>>     if you are in arch/ or something, it would not find the result in\n>>     Documentation/. You can do:\n>> \n>>       git grep vma_area_desc :/\n>> \n>>     to search from the root of the project.\n>\n> I'm running 'git grep' from the top-level directory of the\n> kernel source tree.\n>\n> thanks.\n"},{"id":"539393","messageId":"20260319155326.GA3611913@coredump.intra.peff.net","threadId":"65298","inReplyTo":"2c943182-d5d7-4f72-ab97-8d07bf4ed216@infradead.org","subject":"Re: git grep failure?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-03-19T15:53:26Z","receivedAt":"2026-03-19T15:53:28Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 18, 2026 at 09:42:23PM -0700, Randy Dunlap wrote:\n\n> > I applied the patch and git-grep does produce one line of output (the\n> > instance added by the patch).\n> > \n> > Two possible differences:\n> > \n> >   - are you sure the patch application succeeded?\n> \n> 'git apply filename.patch' succeeded AFAICT. git status shows one\n> untracked file (the one that is added by the patch).\n> Do I need to do 'git commit' also?\n\nAh, I see. I used \"git am\" to apply the patch, which made a commit using\nthe email as the commit message.\n\nAs Junio noted, \"git apply\" by itself will not mark the file as tracked.\nYou would need to \"git add\" it, at which point git-grep would start\nlooking at it (since it only looks at tracked files). And then \"git\ncommit\" if you actually want a commit.\n\nBut at that point, you probably want to be using \"git am\", unless you\ndon't want to use the sender's commit message for some reason. (Though\neven if that is the case, I'd probably use \"git am\" and then \"git commit\n--amend\" to tweak it).\n\n-Peff\n"},{"id":"539403","messageId":"7e8159fb-f7ff-41f0-8955-5ed2dd5dc7fe@infradead.org","threadId":"65298","inReplyTo":"20260319155326.GA3611913@coredump.intra.peff.net","subject":"Re: git grep failure?","fromName":"Randy Dunlap","fromEmail":"rdunlap@infradead.org","sentAt":"2026-03-19T16:47:24Z","receivedAt":"2026-03-19T16:47:26Z","isPatch":false,"sender":{"key":"rdunlap@infradead.org","avatar":null},"body":"\n\nOn 3/19/26 8:53 AM, Jeff King wrote:\n> On Wed, Mar 18, 2026 at 09:42:23PM -0700, Randy Dunlap wrote:\n> \n>>> I applied the patch and git-grep does produce one line of output (the\n>>> instance added by the patch).\n>>>\n>>> Two possible differences:\n>>>\n>>>   - are you sure the patch application succeeded?\n>>\n>> 'git apply filename.patch' succeeded AFAICT. git status shows one\n>> untracked file (the one that is added by the patch).\n>> Do I need to do 'git commit' also?\n> \n> Ah, I see. I used \"git am\" to apply the patch, which made a commit using\n> the email as the commit message.\n> \n> As Junio noted, \"git apply\" by itself will not mark the file as tracked.\n> You would need to \"git add\" it, at which point git-grep would start\n> looking at it (since it only looks at tracked files). And then \"git\n> commit\" if you actually want a commit.\n> \n> But at that point, you probably want to be using \"git am\", unless you\n> don't want to use the sender's commit message for some reason. (Though\n> even if that is the case, I'd probably use \"git am\" and then \"git commit\n> --amend\" to tweak it).\n\nOK, thanks to you and Junio for explaining.\nJust a User Error.\n\n(/me notes that git am and git apply are different in this regard.)\n\n-- \n~Randy\n\n"},{"id":"539410","messageId":"xmqqtsublolr.fsf@gitster.g","threadId":"65298","inReplyTo":"7e8159fb-f7ff-41f0-8955-5ed2dd5dc7fe@infradead.org","subject":"Re: git grep failure?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-19T17:24:00Z","receivedAt":"2026-03-19T17:24:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Randy Dunlap <rdunlap@infradead.org> writes:\n\n> (/me notes that git am and git apply are different in this regard.)\n\nYup, consider that \"git apply\" without \"--index\" is a mere \"make\ngoodness invented for Git available outside Git, as a replacement\nfor 'patch'\", just like \"git diff --no-index\" is a mere \"make\ngoodness invented for git-diff available outside Git, as a\nreplacement for 'diff'\".  Their primary value is that they work\noutside the context of Git without relying on a Git repository, but\nthey have limitations for not relying on a Git repository and data.\n\nThere are better alternatives (i.e., \"apply\" with \"--index\", or\n\"am\"; \"diff\" without \"--no-index\") if you are working with Git.\n"}]}