有没有办法 git grep stdin?

Is there a way to git grep stdin?

提问人:ks1322 提问时间:10/13/2023 更新时间:10/13/2023 访问量:59

问:

我想与从 stdin 获取的输入一起使用。有一个选项,但根据文档,它只允许当前目录中的 grep 文件:git grep--no-index

--无索引

搜索当前目录中不受 Git 管理的文件。

我想使用,因为它有一个选项--function-context,而普通的grep没有它。有没有办法做到这一点?git grepgit grep

git grep stdin

评论

0赞 phd 10/14/2023
不,不可能直接。 旨在通过提交中的 blob 进行 grep。您的问题的解决方案也许是将 stdin 添加到临时文件,运行该文件,然后删除该文件。git grepcatgit grep --no-index --function-context

答: 暂无答案