diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java index 081e8e4c9d0a7b71d9f0c8c98cf0f4aa1667251d..2cf557fb01abde92f5a7d466d2c087828cc84d65 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java @@ -344,6 +344,9 @@ public void test023_createCommitNonAnullii() throws IOException { commit.setMessage("\u00dcbergeeks"); ObjectId cid = new ObjectWriter(db).writeCommit(commit); assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name()); + Commit loadedCommit = db.mapCommit(cid); + assertNotSame(loadedCommit, commit); + assertEquals(commit.getMessage(), loadedCommit.getMessage()); } public void test024_createCommitNonAscii() throws IOException { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java index cdfab7cc384128f8d7c6bdba6327d7159bcf2555..c432563123c4fb89a4f568782ac10f288fc0f1e4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Commit.java @@ -305,17 +305,13 @@ private void decode() { br.read(readBuf); int msgstart = readBuf.length != 0 ? ( readBuf[0] == '\n' ? 1 : 0 ) : 0; - if (encoding != null) { - // TODO: this isn't reliable so we need to guess the encoding from the actual content - author = new PersonIdent(new String(rawAuthor.getBytes(),encoding.name())); - committer = new PersonIdent(new String(rawCommitter.getBytes(),encoding.name())); - message = new String(readBuf,msgstart, readBuf.length-msgstart, encoding.name()); - } else { - // TODO: use config setting / platform / ascii / iso-latin - author = new PersonIdent(new String(rawAuthor.getBytes())); - committer = new PersonIdent(new String(rawCommitter.getBytes())); - message = new String(readBuf, msgstart, readBuf.length-msgstart); - } + // If encoding is not specified, the default for commit is UTF-8 + if (encoding == null) encoding = Constants.CHARSET; + + // TODO: this isn't reliable so we need to guess the encoding from the actual content + author = new PersonIdent(new String(rawAuthor.getBytes(),encoding.name())); + committer = new PersonIdent(new String(rawCommitter.getBytes(),encoding.name())); + message = new String(readBuf,msgstart, readBuf.length-msgstart, encoding.name()); } catch (IOException e) { e.printStackTrace(); } finally {