git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: git@vger.kernel.org
Cc: spearce@spearce.org
Subject: [PATCH 3/4] Decode message when encoding line is present
Date: Sun, 18 Mar 2007 23:16:07 +0100	[thread overview]
Message-ID: <20070318221607.24742.44802.stgit@lathund.dewire.com> (raw)
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();

  parent reply	other threads:[~2007-03-18 22:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-18 22:15 [PATCH 0/4] Eclipse (EGIT) Structured compare Robin Rosenberg
2007-03-18 22:15 ` [PATCH 1/4] Cache tree ObjectId's too Robin Rosenberg
2007-03-18 22:16 ` [PATCH 2/4] Rework tree/commit cache Robin Rosenberg
2007-03-18 22:16 ` Robin Rosenberg [this message]
2007-03-18 22:16 ` [PATCH 4/4] Add support for structured comparison Robin Rosenberg
2007-03-19  2:21 ` [PATCH 0/4] Eclipse (EGIT) Structured compare Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070318221607.24742.44802.stgit@lathund.dewire.com \
    --to=robin.rosenberg@dewire.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).