跟踪子目录中的更改时,“git show”和“git log - ”之间的不一致

时间:2017-02-04 04:43:52

标签: git logging github accumulo

我想在系统历史记录的子目录中找到更改。为此,我使用

git log -- $subdirectory

根据this,这就足够了。在“git log - $ subdirectory”的结果中有一些不显示的提交;但根据

git show $sha

,他们更改了子目录。

例如,当我使用

查看apache-accumulo提交时,在this
git show 31ee26b8ac41844f2a647a5d1484f47da731872a

,我发现它改变了“core / src / main”。更具体地说,我得到以下回复

commit 31ee26b8ac41844f2a647a5d1484f47da731872a
Author: Eric C. Newton <eric.newton@gmail.com>
Date:   Wed Mar 11 14:37:39 2015 -0400

    ACCUMULO-3423 fixed replication bugs with recent refactorings in StatusUtil

diff --git a/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java b/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
index d8ec403..cdb6963 100644
--- a/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
@@ -155,7 +155,7 @@ public class StatusUtil {
   /**
    * @return A {@link Status} for an open file of unspecified length, all of which needs replicating.
    */
-  public static Status openWithUnknownLength(long timeCreated) {
+  public static synchronized Status openWithUnknownLength(long timeCreated) {
     return INF_END_REPLICATION_STATUS_BUILDER.setCreatedTime(timeCreated).build();
   }

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
index 46101c1..498cbdd 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
@@ -319,7 +319,7 @@ public class TabletServerLogger {
               // Need to release
               KeyExtent extent = commitSession.getExtent();
               if (ReplicationConfigurationUtil.isEnabled(extent, tserver.getTableConfiguration(extent))) {
-                Status status = StatusUtil.fileCreated(System.currentTimeMillis());
+                Status status = StatusUtil.openWithUnknownLength(System.currentTimeMillis());
                 log.debug("Writing " + ProtobufUtil.toString(status) + " to metadata table for " + copy.getFileName());
                 // Got some new WALs, note this in the metadata table
                 ReplicationTableUtil.updateFiles(tserver, commitSession.getExtent(), copy.getFileName(), status);

git log -- core/src/main | grep 31ee26b8ac41844f2a647a5d1484f47da731872a

没有显示提交。

我找不到任何答案!我很感激任何见解!谢谢!

1 个答案:

答案 0 :(得分:2)

首先,apache/accumulo中没有.gitmodules个文件,因此我们根本不是在讨论 git submodules 。 相反,您可以考虑记录子文件夹或子目录。不是子模块。

第二

C:\Users\vonc\prog\git\accumulo>git show --name-only 31ee26b8a
commit 31ee26b8ac41844f2a647a5d1484f47da731872a
Author: Eric C. Newton <eric.newton@gmail.com>
Date:   Wed Mar 11 14:37:39 2015 -0400

    ACCUMULO-3423 fixed replication bugs with recent refactorings in StatusUtil

core/src/main/java/org/apache/accumulo/core/replication/StatusUtil.java
server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java

这是指StatusUtil.java,现在位于src/main/java/org/apache/accumulo/server/replication

换句话说,该文件在提交后已移动 git log默认只列出重命名的文件

--follow添加到git log

C:\Users\vonc\prog\git\accumulo>git log --graph --all --oneline --decorate  --follow -- core\src\main |grep 31ee26
| * | | | | | | | | | | | | | | | | | 31ee26b8a ACCUMULO-3423 fixed replication bugs with recent refactorings in StatusUtil

或者:

C:\Users\vonc\prog\git\accumulo>git log --follow -- core\src\main|grep 31ee26
commit 31ee26b8ac41844f2a647a5d1484f47da731872a

请参阅&#34; Why might git log not show history for a moved file, and what can I do about it?&#34;