aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-11-02 14:12:00 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-11-04 19:12:13 -0700
commitc27e1daa55255416d93e3a019f556f0ca90fd410 (patch)
tree4081b8d283df532a610c763183d30fb1aba6608c /org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
parent009507ca2eafe1c6218ca3779348452495dcd3a3 (diff)
downloadjgit-c27e1daa55255416d93e3a019f556f0ca90fd410.tar.gz
jgit-c27e1daa55255416d93e3a019f556f0ca90fd410.zip
Refactor tree entry formatting into a common class
Instead of hiding this logic inside of DirCacheTree and the legacy Tree type, pull it into a common place where we can reuse it by creating tree records in a buffer that can be passed directly into the ObjectInserter. This allows us to avoid some copying, as the inserter can be given the internal buffer of the formatter. Because we trust these two callers to feed us records in the proper order, without '/' in the names, and without duplicate names in the same tree, we don't do any validation inside of the formatter itself. To protect themselves from making ordering errors, developers should continue to use DirCache to process edits to source code trees. Change-Id: Idf7f10e736d4a44ccdf8afe060535d7b0554a92f Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
index 43e4dd9c15..f295f5b72f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
@@ -223,6 +223,23 @@ public abstract class FileMode {
}
/**
+ * Copy this mode as a sequence of octal US-ASCII bytes.
+ *
+ * The mode is copied as a sequence of octal digits using the US-ASCII
+ * character encoding. The sequence does not use a leading '0' prefix to
+ * indicate octal notation. This method is suitable for generation of a mode
+ * string within a GIT tree object.
+ *
+ * @param buf
+ * buffer to copy the mode to.
+ * @param ptr
+ * position within {@code buf} for first digit.
+ */
+ public void copyTo(byte[] buf, int ptr) {
+ System.arraycopy(octalBytes, 0, buf, ptr, octalBytes.length);
+ }
+
+ /**
* @return the number of bytes written by {@link #copyTo(OutputStream)}.
*/
public int copyToLength() {