aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-03-30 11:03:33 +0100
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-06-14 19:52:29 -0400
commitb0ffacf1226e3c0b0d8fd6ed0beb7311e508dc14 (patch)
tree858ed9000b96402b568c8aac7df93dc0ff927b6e /org.eclipse.jgit.test
parentc693a232b042fab7748dce956f642a77865d3482 (diff)
downloadjgit-b0ffacf1226e3c0b0d8fd6ed0beb7311e508dc14.tar.gz
jgit-b0ffacf1226e3c0b0d8fd6ed0beb7311e508dc14.zip
Recognize CRLF when parsing the short message of a commit or tag
Bug: 400707 Change-Id: I9b09bb88528af465018fc0278f5441f7e6b75986
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java13
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java12
2 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
index 574f85c91a..beda2a7b97 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java
@@ -383,6 +383,19 @@ public class RevCommitParseTest extends RepositoryTestCase {
assertEquals(src.getMessage(), p.getFullMessage());
}
+ @Test
+ public void testParse_GitStyleMessageWithCRLF() throws Exception {
+ final String shortMsgIn = "This fixes a\r\nbug.\r\n\r\n";
+ final String shortMsg = "This fixes a bug.";
+ final String body = "We do it with magic and pixie dust\r\nand stuff.\r\n"
+ + "\r\n\r\n"
+ + "Signed-off-by: A U. Thor <author@example.com>\r\n";
+ final String fullMsg = shortMsgIn + "\r\n" + "\r\n" + body;
+ final RevCommit c = create(fullMsg);
+ assertEquals(fullMsg, c.getFullMessage());
+ assertEquals(shortMsg, c.getShortMessage());
+ }
+
private static ObjectId id(final String str) {
return ObjectId.fromString(str);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java
index d7b92ade9d..86fed22afe 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java
@@ -91,4 +91,16 @@ public class StringUtilsTest {
assertTrue(StringUtils.equalsIgnoreCase("A", "a"));
assertTrue(StringUtils.equalsIgnoreCase("a", "A"));
}
+
+ @Test
+ public void testReplaceLineBreaks() {
+ assertEquals("a b c ",
+ StringUtils.replaceLineBreaksWithSpace("a b\nc\r"));
+ assertEquals("a b c ",
+ StringUtils.replaceLineBreaksWithSpace("a b\nc\n"));
+ assertEquals("a b c ",
+ StringUtils.replaceLineBreaksWithSpace("a b\nc\r\n"));
+ assertEquals("a b c d",
+ StringUtils.replaceLineBreaksWithSpace("a\r\nb\nc d"));
+ }
}