[EGIT PATCH 08/10] TreeEntry: Accessors for full raw name and mode bits
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/TreeEntry.java | 23 ++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
index 8d46230..e73f5d5 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/TreeEntry.java
@@ -19,6 +19,8 @@ package org.spearce.jgit.lib;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import org.spearce.jgit.lib.GitIndex.Entry;
+
/**
* This class represents an entry in a tree, like a blob or another tree.
*/
@@ -189,6 +191,14 @@ public abstract class TreeEntry implements Comparable {
return r.toString();
}
+ /**
+ * @return repository relative name of the entry
+ * FIXME better encoding
+ */
+ public byte[] getFullNameUTF8() {
+ return getFullName().getBytes();
+ }
+
public int compareTo(final Object o) {
if (this == o)
return 0;
@@ -211,6 +221,19 @@ public abstract class TreeEntry implements Comparable {
}
/**
+ * Helper for accessing tree/blob/index methods.
+ *
+ * @param i
+ * @return '/' for Tre entries and NUL for non-treeish objects
+ */
+ final public static int lastChar(Entry i) {
+ // FIXME, gitlink etc. Currently Trees cannot appear in the
+ // index so '\0' is always returned, except maybe for submodules
+ // which we do not support yet.
+ return FileMode.TREE.equals(i.getModeBits()) ? '/' : '\0';
+ }
+
+ /**
* See @{link {@link #accept(TreeVisitor, int)}.
*
* @param tv
--
1.5.4.2