今天早些时候,我正在搜索将函数名称从getReportHtml
更改为getReport
的提交。
我无法使用镐找到它,所以我通过手动搜索找到了它。
现在我知道哪个提交有更改,我可以看到我的git diff输出中的更改:
- function getReportHtml(filters) {
+ function getReport(type, filters) {
我尝试了以下搜索:
git log -SgetReportHtml
git log -SgetReportHtml --diff-filter=M
git log -GgetReportHtml
他们找到了提交,但没有改变名称。
这是git-log手册页的相关部分:
-S<string>
Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter's use.
It is useful when you're looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively
to feed the interesting block in the preimage back into -S, and keep going until you get the very first version of the block.
-G<regex>
Look for differences whose patch text contains added/removed lines that match <regex>.
引入更改的提交确实改变了'getReportHtml'的出现次数。那么为什么镐不能找到呢?