git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Mar 18, 2007, 22:16 UTC
Message-ID
<20070318221607.24742.44802.stgit@lathund.dewire.com>
In-Reply-To
<20070318220711.24742.90943.stgit@lathund.dewire.com>

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();
Previous: Robin RosenbergNext: Robin Rosenberg
Message 4 of 6 in “Eclipse (EGIT) Structured compare”
  1. 0/4 Eclipse (EGIT) Structured compareRobin Rosenberg, Mar 18, 2007
  2. 1/4 Cache tree ObjectId's tooRobin Rosenberg, Mar 18, 2007
  3. 2/4 Rework tree/commit cacheRobin Rosenberg, Mar 18, 2007
  4. 3/4 Decode message when encoding line is presentRobin Rosenberg, Mar 18, 2007
  5. 4/4 Add support for structured comparison.Robin Rosenberg, Mar 18, 2007
  6. Shawn O. PearceMar 19, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.