[JGIT PATCH 09/13] Add AnyObjectId.copyTo(StringBuilder)
From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:49
Subsystem:
the rest · Maintainer:
Linus Torvalds
This makes it easier to append an ObjectId onto a StringBuilder. Signed-off-by: Shawn O. Pearce <redacted> --- .../src/org/spearce/jgit/lib/AnyObjectId.java | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
index 943d916..3ec00ea 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java@@ -387,7 +387,22 @@ public void copyTo(final Writer w) throws IOException { */ public void copyTo(final char[] tmp, final Writer w) throws IOException { toHexCharArray(tmp); - w.write(tmp); + w.write(tmp, 0, STR_LEN); + } + + /** + * Copy this ObjectId to a StringBuilder in hex format. + * + * @param tmp + * temporary char array to buffer construct into before writing. + * Must be at least large enough to hold 2 digits for each byte + * of object id (40 characters or larger). + * @param w + * the string to append onto. + */ + public void copyTo(final char[] tmp, final StringBuilder w) { + toHexCharArray(tmp); + w.append(tmp, 0, STR_LEN); } private char[] toHexCharArray() {
--
1.6.1.rc4.301.g5497a