【问题标题】:`git -S` doesn't find all commits`git -S` 找不到所有提交
【发布时间】:2017-05-14 08:34:28
【问题描述】:

考虑以下打字稿:

$ 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 的提交?

【问题讨论】:

    标签: git revision-history


    【解决方案1】:

    来自the documentation for git log(但我强调了):

    -S&lt;string&gt;

           寻找改变文件中指定字符串(即添加/删除)的出现次数的差异。供脚本编写者使用。

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

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

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

    【讨论】:

      猜你喜欢
      • 2014-08-17
      • 2014-02-22
      • 2011-04-06
      • 2012-11-03
      • 2010-11-20
      • 2021-04-29
      • 2014-01-07
      • 2020-11-23
      • 2011-06-02
      相关资源
      最近更新 更多