`git -S` 没有找到所有提交

`git -S` doesn't find all commits

考虑以下打字稿:

$ git clone git@github.com:laravel/framework.git
$ cd framework

$ git log --all --oneline --graph --decorate
...
| * | | | | | 07bb4d7 fix
| * | | | | | 0c2b7da Use the current timestamp as a default.
| * | | | | | 26cd65e (tag: v5.2.7) increment version

$ git show 0c2b7da
commit 0c2b7da2635f7bbbaf63d1b93fa817232bdd9d65
Author: Taylor Otwell <taylorotwell@gmail.com>
Date:   Thu Jan 7 08:01:39 2016 -0600

    Use the current timestamp as a default.

diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php
index fca8e89..7e179aa 100755
--- a/src/Illuminate/Database/Schema/Blueprint.php
+++ b/src/Illuminate/Database/Schema/Blueprint.php
@@ -791,9 +791,9 @@ class Blueprint
      */
     public function timestamps()
     {
-        $this->timestamp('created_at');
+        $this->timestamp('created_at')->useCurrent();

-        $this->timestamp('updated_at');
+        $this->timestamp('updated_at')->useCurrent();
     }

     /**

$ git log -p -m --full-history 07bb4d7 -Stimestamp src/Illuminate/Database/Schema/Blueprint.php

您不会在上一个命令的输出中看到此提交。但如果你这样做:

$ git log -p origin/master -Stimestamp src/Illuminate/Database/Schema/Blueprint.php

你会看到这个:

commit 720a116897a4cc6780fa22f34d30c5986eafc581
Author: Taylor Otwell <taylorotwell@gmail.com>
Date:   Wed Feb 3 08:13:22 2016 -0600

    make timestamps nullable by default

diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php
index fca8e89..6cfab6f 100755
--- a/src/Illuminate/Database/Schema/Blueprint.php
+++ b/src/Illuminate/Database/Schema/Blueprint.php
@@ -779,9 +779,7 @@ class Blueprint
      */
     public function nullableTimestamps()
     {
-        $this->timestamp('created_at')->nullable();
-
-        $this->timestamp('updated_at')->nullable();
+        return $this->timestamps();
     }

     /**
@@ -791,9 +789,9 @@ class Blueprint
      */
     public function timestamps()
     {
-        $this->timestamp('created_at');
+        $this->timestamp('created_at')->nullable();

-        $this->timestamp('updated_at');
+        $this->timestamp('updated_at')->nullable();
     }

     /**
@@ -803,9 +801,9 @@ class Blueprint
      */
     public function timestampsTz()
     {
-        $this->timestampTz('created_at');
+        $this->timestampTz('created_at')->nullable();

-        $this->timestampTz('updated_at');
+        $this->timestampTz('updated_at')->nullable();
     }

     /**

我做错了什么?如何找到更改方法 timestamps 的提交?

来自 the documentation for 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.

未显示的提交在两个版本(更改之前和之后)中 单词 timestamp 的出现次数 相同。该词的实际用法不同,但出现次数相同。

显示的提交改变了出现的次数:第一个 diff-hunk 将单词 timestamp 的两个副本替换为单词 timestamp 的一个副本。 =12=](两个文字 timestamp 单词被替换为一个 timestamp-inside-the-word-timestamps)。

您几乎肯定需要 -G 标志,它在 -S 标志的正下方进行了描述。请注意 -G 采用正则表达式,而不是简单的字符串,尽管单词 timestamp 中没有正则表达式字符,因此对于这种情况没有区别。 (但您可能想使用 --perl-regexp 来获得完整的 Perl 风格的正则表达式,这样您就可以搜索 \btimestamp\b,意思是“时间戳一词,但被非词字符包围”,即,不要t匹配timestampsthetimestamptwotimestamps,所有包含timestamp.)