[git] do not loose commit which messages do not contain \n while reading details...
authorJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Wed, 2 Nov 2016 13:39:57 +0000 (16:39 +0300)
committerJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Wed, 2 Nov 2016 13:42:21 +0000 (16:42 +0300)
plugins/git4idea/src/git4idea/history/GitHistoryUtils.java
plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java

index 39c24c130ec02bc99f2aa6d514c3676e30233f35..5109e61a09ae5c3f77e2ed4b1a8689db4f1832f3 100644 (file)
@@ -593,7 +593,7 @@ public class GitHistoryUtils {
                 output.setLength(0);
               }
               output.append(tail);
-              foundRecordEnd.set(false);
+              foundRecordEnd.set(tail.contains(GitLogParser.RECORD_END));
             }
           }
           catch (Exception e) {
index fe9b0c1835a5ddce7be5535cb890664b243fca87..98fe9905781f79884a03b4370d44d8cc13c70794 100644 (file)
@@ -406,6 +406,28 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest {
     assertEquals(message, lastCommit.getFullMessage());
   }
 
+  @Test
+  public void testLoadingDetailsWithoutChanges() throws Exception {
+    List<String> expected = ContainerUtil.newArrayList();
+
+    String messageFile = "message.txt";
+    touch(messageFile, "");
+
+    int commitCount = 100;
+    for (int i = 0; i < commitCount; i++) {
+      touch("file.txt", "content number " + i);
+      add();
+      git("commit --allow-empty-message -F " + messageFile);
+      expected.add(last());
+    }
+    expected = ContainerUtil.reverse(expected);
+
+    List<String> actualMessages =
+      GitHistoryUtils.loadDetails(myProject, myRepo.getRoot(), true, false, GitLogRecord::getHash, "--max-count=" + commitCount);
+
+    assertEquals(expected, actualMessages);
+  }
+
   private void assertHistory(@NotNull List<? extends VcsFileRevision> actualRevisions) throws IOException, VcsException {
     assertEquals("Incorrect number of commits in history", myRevisions.size(), actualRevisions.size());
     for (int i = 0; i < actualRevisions.size(); i++) {