[git] add test for loading commits with body containing \u0001 character
authorJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Mon, 24 Oct 2016 01:29:49 +0000 (04:29 +0300)
committerJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Thu, 27 Oct 2016 21:16:13 +0000 (00:16 +0300)
plugins/git4idea/tests/git4idea/history/GitHistoryUtilsTest.java

index 5affccdc2d99088e9371957ebc319db78d38dc85..fe9b0c1835a5ddce7be5535cb890664b243fca87 100644 (file)
@@ -26,6 +26,8 @@ import com.intellij.util.ArrayUtil;
 import com.intellij.util.Consumer;
 import com.intellij.util.ExceptionUtil;
 import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.VcsFullCommitDetails;
 import com.intellij.vcsUtil.VcsUtil;
 import git4idea.GitFileRevision;
 import git4idea.GitRevisionNumber;
@@ -389,6 +391,21 @@ public class GitHistoryUtilsTest extends GitSingleRepoTest {
     }
   }
 
+  @Test
+  public void testLoadingDetailsWithU0001Character() throws Exception {
+    List<VcsFullCommitDetails> details = ContainerUtil.newArrayList();
+
+    String message = "subject containing \u0001 symbol in it\n\ncommit body containing \u0001 symbol in it";
+    touch("file.txt", "content");
+    addCommit(message);
+
+    GitHistoryUtils.loadAllDetails(myProject, myRepo.getRoot(), details::add);
+
+    VcsFullCommitDetails lastCommit = ContainerUtil.getFirstItem(details);
+    assertNotNull(lastCommit);
+    assertEquals(message, lastCommit.getFullMessage());
+  }
+
   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++) {