[git] do not loose commit which messages do not contain \n while reading details without changes

This commit is contained in:
Julia Beliaeva
2016-11-02 16:42:21 +03:00
parent 80429eadef
commit 7620e8e734
2 changed files with 23 additions and 1 deletions
@@ -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) {
@@ -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++) {