Thread (19 messages) flat view 19 messages, 1 author, 2016-06-15
DORMANTno replies

[EGIT PATCH 14/26] Support creating a new DirCacheEntry for an arbitrary path

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:08
Subsystem: the rest · Maintainer: Linus Torvalds

Applications which use a DirCacheBuilder may need to build their own
DirCacheEntry in order to insert new records into the index file.

Signed-off-by: Shawn O. Pearce <redacted>
---
 .../org/spearce/jgit/dircache/DirCacheEntry.java   |   24 ++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
index 8ca8f22..eba2678 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
@@ -114,6 +114,30 @@ public class DirCacheEntry {
 			in.skip(expLen - actLen);
 	}
 
+	/**
+	 * Create an empty entry.
+	 * 
+	 * @param newPath
+	 *            name of the cache entry.
+	 */
+	public DirCacheEntry(final String newPath) {
+		this(Constants.encode(newPath));
+	}
+
+	/**
+	 * Create an empty entry.
+	 * 
+	 * @param newPath
+	 *            name of the cache entry, in the standard encoding.
+	 */
+	public DirCacheEntry(final byte[] newPath) {
+		info = new byte[INFO_LEN];
+		infoOffset = 0;
+
+		path = newPath;
+		NB.encodeInt16(info, infoOffset + P_FLAGS, path.length);
+	}
+
 	void write(final OutputStream os) throws IOException {
 		final int pathLen = path.length;
 		os.write(info, infoOffset, INFO_LEN);
-- 
1.6.0.rc2.22.g71b99
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help