{"thread":{"id":"62724","subject":"Change the grep command called by git with alternative tools, such as ug.","startedAt":"2025-01-02T11:48:55Z","lastAt":"2025-01-02T15:28:26Z","messageCount":5,"participants":["Hongyi Zhao","Matěj Cepl","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"509792","messageId":"CAGP6POJX9GFsNkgGd7o9Pr-tFoz0sgRk51vVG4P0Kn1DPZe+3Q@mail.gmail.com","threadId":"62724","inReplyTo":null,"subject":"Change the grep command called by git with alternative tools, such as ug.","fromName":"Hongyi Zhao","fromEmail":"hongyi.zhao@gmail.com","sentAt":"2025-01-02T11:48:41Z","receivedAt":"2025-01-02T11:48:55Z","isPatch":false,"sender":{"key":"hongyi.zhao@gmail.com","avatar":null},"body":"Hi there,\n\nCan I change the grep command called by git with alternative tools,\nsuch as ug [1]?\n\nSay in the following command:\n\n$ git grep -i jobflow\n\nI tried to replace grep with ug, but failed as follows:\n\n$ git ug -i jobflow\ngit: 'ug' is not a git command. See 'git --help'.\n\nThe most similar command is\n    gui\n\n\n[1] https://github.com/Genivia/ugrep\n\nRegards,\nZhao\n-- \nAssoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>\nTheory and Simulation of Materials\nHebei Vocational University of Technology and Engineering\nNo. 473, Quannan West Street, Xindu District, Xingtai, Hebei province\n"},{"id":"509794","messageId":"D6RLU4BY374I.GQY9MLMV1AZJ@cepl.eu","threadId":"62724","inReplyTo":"CAGP6POJX9GFsNkgGd7o9Pr-tFoz0sgRk51vVG4P0Kn1DPZe+3Q@mail.gmail.com","subject":"Re: Change the grep command called by git with alternative tools, such as ug.","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2025-01-02T13:00:23Z","receivedAt":"2025-01-02T13:00:25Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Thu Jan 2, 2025 at 12:49 PM CET, Hongyi Zhao wrote:\n> $ git grep -i jobflow\n>\n> I tried to replace grep with ug, but failed as follows:\n\nAFAIK, git grep doesn’t use external grep(1) binary on its\nown, but rather it uses its own (and slightly different)\nalgorithm. Certainly, calling git-ug (or git-rg) will do\nabsolutely nothing as long as you have no git-ug binary in your\n$PATH.\n\nBest,\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@en.osm.town\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nWhen God put a calling on your life, He already factored in your\nstupidity.\n  -- Unknown, mentioned in a sermon\n\n"},{"id":"509795","messageId":"CAGP6POKLdTpwsaGo-oyGAiYJMRzwXN06rv3+V7v5QbL6xtDROw@mail.gmail.com","threadId":"62724","inReplyTo":"D6RLU4BY374I.GQY9MLMV1AZJ@cepl.eu","subject":"Re: Change the grep command called by git with alternative tools, such as ug.","fromName":"Hongyi Zhao","fromEmail":"hongyi.zhao@gmail.com","sentAt":"2025-01-02T13:39:13Z","receivedAt":"2025-01-02T13:39:28Z","isPatch":false,"sender":{"key":"hongyi.zhao@gmail.com","avatar":null},"body":"On Thu, Jan 2, 2025 at 9:00 PM Matěj Cepl <mcepl@cepl.eu> wrote:\n>\n> On Thu Jan 2, 2025 at 12:49 PM CET, Hongyi Zhao wrote:\n> > $ git grep -i jobflow\n> >\n> > I tried to replace grep with ug, but failed as follows:\n>\n> AFAIK, git grep doesn’t use external grep(1) binary on its\n> own, but rather it uses its own (and slightly different)\n> algorithm. Certainly, calling git-ug (or git-rg) will do\n> absolutely nothing as long as you have no git-ug binary in your\n> $PATH.\n\nDo you mean: by linking ug as git-ug will do the trick?\n\n> Best,\n>\n> Matěj\n\nZhao\n"},{"id":"509799","messageId":"D6ROC4RAYQS1.3V2K2W5GMAEYR@cepl.eu","threadId":"62724","inReplyTo":"CAGP6POKLdTpwsaGo-oyGAiYJMRzwXN06rv3+V7v5QbL6xtDROw@mail.gmail.com","subject":"Re: Change the grep command called by git with alternative tools, such as ug.","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2025-01-02T14:57:56Z","receivedAt":"2025-01-02T14:57:59Z","isPatch":false,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Thu Jan 2, 2025 at 2:39 PM CET, Hongyi Zhao wrote:\n> Do you mean: by linking ug as git-ug will do the trick?\n\nNo, you would have to rewrite git-grep to use external grep-like\nprogram. I am not sure whether there isn’t such project already\nout there.\n\nBest,\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@en.osm.town\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nTo the well-organized mind, death is but the next great adventure.\n  -- Albus Dumbledore\n\n"},{"id":"509802","messageId":"Z3awl9gToJjwap-G@google.com","threadId":"62724","inReplyTo":"D6ROC4RAYQS1.3V2K2W5GMAEYR@cepl.eu","subject":"Re: Change the grep command called by git with alternative tools, such as ug.","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2025-01-02T15:28:23Z","receivedAt":"2025-01-02T15:28:26Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nMatěj Cepl wrote:\n> On Thu Jan 2, 2025 at 2:39 PM CET, Hongyi Zhao wrote:\n\n>> Do you mean: by linking ug as git-ug will do the trick?\n>\n> No, you would have to rewrite git-grep to use external grep-like\n> program. I am not sure whether there isn’t such project already\n> out there.\n\nThe key question is - what are you trying to do?  \"git grep\" is able\nto search inside historical commits, the working copy, the index, and\nso on.  Do we want to search in the same way to find files with hits\n(for efficiency reasons, for example) and then use an external program\nto find the matches within those files?  For that kind of application\nI might do some scripting around \"git grep --name-only\", but I can\nalso imagine that your application is different.  Depending on the\ngoal, it could be something a git command already supports, an implied\nfeature request for git, or something that the external search tool\nmight need to learn.\n\nIn other words, Matěj's reply is spot on in describing the current\nbehavior: \"git grep\" doesn't call out to an external grep tool.  But\nas for the desired behavior, we'd need to know more about the use case\nto figure it out.\n\nThanks,\nJonathan\n"}]}