1

I would like to find the changes in a subdirectory over the history of a system. For that purpose, I use

git log -- $subdirectory

According to this, that would suffice. There are some commits that do not appear in the result of "git log -- $subdirectory"; however according to

git show $sha

, they change the subdirectory.

For example, in apache-accumulo when I look at this commit using

git show 31ee26b8ac41844f2a647a5d1484f47da731872a

, I see that it changes "core/src/main". To be more specific I get the following response

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);

; while

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

does not show that commit.

I could not find any answer for that! I would appreciate any insight! Thanks!

Community
  • 1
  • 1
  • In the initial question, I mentioned "submodule" while I meant "subdirectory". Sorry for the confusion –  Feb 05 '17 at 00:53

1 Answers1

2

First, there is no .gitmodules file in apache/accumulo, so we are not talking about git submodules at all.
Instead, you might consider log for a subfolder or subdirectory. Not a submodule.

Second:

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

This refers to StatusUtil.java, which is now in src/main/java/org/apache/accumulo/server/replication

In other word, that file was moved since that commit, and git log would only list renamed files by default.

Add --follow to 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

Or:

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

See "Why might git log not show history for a moved file, and what can I do about it?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thanks for your informative explanation! Considering the git-log documents, --follow works only for a single file. Is there any way to use git follow for a all files in a directory? –  Feb 05 '17 at 02:13
  • 1
    @PooyanBehnamghader Git does not track folders: a `log --follow` for a folder will include any commits with changes for any files within that folder, even if those files where moved/renamed before. So in that sense, using the folder is a way to "use Git follow for a all files in a directory". – VonC Feb 05 '17 at 05:06
  • 1
    Thanks @VonC for the info. I found the following information at [link](http://stackoverflow.com/questions/38870925/is-there-a-trick-to-git-log-follow-a-directory-which-has-been-renamed) "The --follow option can only follow one file. So if you could somehow manage to get it to apply to a directory, Git would first turn the directory into a set of files, then pick one of those files and follow just that one." –  Feb 06 '17 at 16:44
  • @PooyanBehnamghader yes, that is similar to what I said in my previous comment – VonC Feb 06 '17 at 17:00