[PATCH 3/4] Decode message when encoding line is present

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Cc: <spearce@...>
Date: Sunday, March 18, 2007 - 6:16 pm

Seems we left the newline between the encoding and the rest
of the message

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 .../src/org/spearce/jgit/lib/Commit.java           |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
index 4356149..c5c65c4 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
@@ -161,16 +161,18 @@ public class Commit implements Treeish {
 				}
 				byte[] readBuf = new byte[br.available()]; // in-memory stream so this is all bytes left
 				br.read(readBuf);
+				int msgstart = readBuf[0] == '\n' ? 1 : 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,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);
+					message = new String(readBuf, msgstart, readBuf.length-msgstart);
 				}
 			} catch (IOException e) {
 				e.printStackTrace();

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/4] Eclipse (EGIT) Structured compare, Robin Rosenberg, (Sun Mar 18, 6:15 pm)
Re: [PATCH 0/4] Eclipse (EGIT) Structured compare, Shawn O. Pearce, (Sun Mar 18, 10:21 pm)
[PATCH 4/4] Add support for structured comparison., Robin Rosenberg, (Sun Mar 18, 6:16 pm)
[PATCH 2/4] Rework tree/commit cache, Robin Rosenberg, (Sun Mar 18, 6:16 pm)
[PATCH 3/4] Decode message when encoding line is present, Robin Rosenberg, (Sun Mar 18, 6:16 pm)
[PATCH 1/4] Cache tree ObjectId's too, Robin Rosenberg, (Sun Mar 18, 6:15 pm)