|
|
@ -44,7 +44,7 @@ |
|
|
|
package org.eclipse.jgit.revwalk; |
|
|
|
package org.eclipse.jgit.revwalk; |
|
|
|
|
|
|
|
|
|
|
|
import static java.nio.charset.StandardCharsets.ISO_8859_1; |
|
|
|
import static java.nio.charset.StandardCharsets.ISO_8859_1; |
|
|
|
import static org.eclipse.jgit.lib.Constants.CHARSET; |
|
|
|
import static java.nio.charset.StandardCharsets.UTF_8; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertNotNull; |
|
|
|
import static org.junit.Assert.assertNotNull; |
|
|
|
import static org.junit.Assert.assertNull; |
|
|
|
import static org.junit.Assert.assertNull; |
|
|
@ -114,7 +114,7 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
assertNull(c.getTree()); |
|
|
|
assertNull(c.getTree()); |
|
|
|
assertNull(c.parents); |
|
|
|
assertNull(c.parents); |
|
|
|
|
|
|
|
|
|
|
|
c.parseCanonical(rw, body.toString().getBytes(CHARSET)); |
|
|
|
c.parseCanonical(rw, body.toString().getBytes(UTF_8)); |
|
|
|
assertNotNull(c.getTree()); |
|
|
|
assertNotNull(c.getTree()); |
|
|
|
assertEquals(treeId, c.getTree().getId()); |
|
|
|
assertEquals(treeId, c.getTree().getId()); |
|
|
|
assertSame(rw.lookupTree(treeId), c.getTree()); |
|
|
|
assertSame(rw.lookupTree(treeId), c.getTree()); |
|
|
@ -148,7 +148,7 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -161,7 +161,7 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals("", c.getFullMessage()); |
|
|
|
assertEquals("", c.getFullMessage()); |
|
|
|
assertEquals("", c.getShortMessage()); |
|
|
|
assertEquals("", c.getShortMessage()); |
|
|
@ -176,7 +176,7 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent()); |
|
|
|
assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent()); |
|
|
|
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent()); |
|
|
|
assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent()); |
|
|
@ -185,18 +185,18 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParse_implicit_UTF8_encoded() throws Exception { |
|
|
|
public void testParse_implicit_UTF8_encoded() throws Exception { |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); |
|
|
|
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); |
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
|
|
|
|
|
|
|
|
|
assertSame(Constants.CHARSET, c.getEncoding()); |
|
|
|
assertSame(UTF_8, c.getEncoding()); |
|
|
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName()); |
|
|
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); |
|
|
@ -205,18 +205,18 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParse_implicit_mixed_encoded() throws Exception { |
|
|
|
public void testParse_implicit_mixed_encoded() throws Exception { |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); |
|
|
|
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); |
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
|
|
|
|
|
|
|
|
|
assertSame(Constants.CHARSET, c.getEncoding()); |
|
|
|
assertSame(UTF_8, c.getEncoding()); |
|
|
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName()); |
|
|
|
assertEquals("F\u00f6r fattare", c.getAuthorIdent().getName()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); |
|
|
|
assertEquals("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); |
|
|
@ -260,14 +260,14 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParse_explicit_bad_encoded() throws Exception { |
|
|
|
public void testParse_explicit_bad_encoded() throws Exception { |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); |
|
|
|
b.write("encoding EUC-JP\n".getBytes(CHARSET)); |
|
|
|
b.write("encoding EUC-JP\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("Hi\n".getBytes(CHARSET)); |
|
|
|
b.write("Hi\n".getBytes(UTF_8)); |
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
@ -291,14 +291,14 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParse_explicit_bad_encoded2() throws Exception { |
|
|
|
public void testParse_explicit_bad_encoded2() throws Exception { |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
final ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET)); |
|
|
|
b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); |
|
|
|
b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); |
|
|
|
b.write("encoding ISO-8859-1\n".getBytes(CHARSET)); |
|
|
|
b.write("encoding ISO-8859-1\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); |
|
|
|
b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("Hi\n".getBytes(CHARSET)); |
|
|
|
b.write("Hi\n".getBytes(UTF_8)); |
|
|
|
final RevCommit c; |
|
|
|
final RevCommit c; |
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
|
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
|
c.parseCanonical(new RevWalk(db), b.toByteArray()); |
|
|
@ -313,13 +313,13 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
public void testParse_incorrectUtf8Name() throws Exception { |
|
|
|
public void testParse_incorrectUtf8Name() throws Exception { |
|
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" |
|
|
|
.getBytes(CHARSET)); |
|
|
|
.getBytes(UTF_8)); |
|
|
|
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET)); |
|
|
|
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8)); |
|
|
|
b.write("committer co <c@example.com> 1218123390 -0500\n" |
|
|
|
b.write("committer co <c@example.com> 1218123390 -0500\n" |
|
|
|
.getBytes(CHARSET)); |
|
|
|
.getBytes(UTF_8)); |
|
|
|
b.write("encoding 'utf8'\n".getBytes(CHARSET)); |
|
|
|
b.write("encoding 'utf8'\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); |
|
|
|
b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); |
|
|
|
|
|
|
|
|
|
|
|
RevCommit c = new RevCommit( |
|
|
|
RevCommit c = new RevCommit( |
|
|
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
@ -338,12 +338,12 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParse_illegalEncoding() throws Exception { |
|
|
|
public void testParse_illegalEncoding() throws Exception { |
|
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); |
|
|
|
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET)); |
|
|
|
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8)); |
|
|
|
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); |
|
|
|
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); |
|
|
|
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET)); |
|
|
|
b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("message\n".getBytes(CHARSET)); |
|
|
|
b.write("message\n".getBytes(UTF_8)); |
|
|
|
|
|
|
|
|
|
|
|
RevCommit c = new RevCommit( |
|
|
|
RevCommit c = new RevCommit( |
|
|
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
@ -365,12 +365,12 @@ public class RevCommitParseTest extends RepositoryTestCase { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testParse_unsupportedEncoding() throws Exception { |
|
|
|
public void testParse_unsupportedEncoding() throws Exception { |
|
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream b = new ByteArrayOutputStream(); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); |
|
|
|
b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); |
|
|
|
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET)); |
|
|
|
b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8)); |
|
|
|
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); |
|
|
|
b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); |
|
|
|
b.write("encoding it_IT.UTF8\n".getBytes(CHARSET)); |
|
|
|
b.write("encoding it_IT.UTF8\n".getBytes(UTF_8)); |
|
|
|
b.write("\n".getBytes(CHARSET)); |
|
|
|
b.write("\n".getBytes(UTF_8)); |
|
|
|
b.write("message\n".getBytes(CHARSET)); |
|
|
|
b.write("message\n".getBytes(UTF_8)); |
|
|
|
|
|
|
|
|
|
|
|
RevCommit c = new RevCommit( |
|
|
|
RevCommit c = new RevCommit( |
|
|
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|
id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); |
|
|
|