git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 08/10] TreeEntry: Accessors for full raw name and mode bits

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Feb 23, 2008, 23:50 UTC
Message-ID
<1203810643-28819-9-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<1203810643-28819-8-git-send-email-robin.rosenberg@dewire.com>
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
Previous: Robin RosenbergNext: Robin Rosenberg
Message 9 of 12 in “[EGIT] Sort order from hell fixes, take 2”
  1. Robin RosenbergFeb 23, 2008
  2. 01/10 Tighten IndexDiffTest to make it test better what it claims to testRobin Rosenberg, Feb 23, 2008
  3. 02/10 Extend IndexDiffTest with more testsRobin Rosenberg, Feb 23, 2008
  4. 03/10 WorkdirCheckout: more test for names that are closeRobin Rosenberg, Feb 23, 2008
  5. 04/10 Split a big test in ReadTreeTest into smaller testsRobin Rosenberg, Feb 23, 2008
  6. 05/10 Fix git sort order compare bugRobin Rosenberg, Feb 23, 2008
  7. 06/10 Use the proper comparison algorithmRobin Rosenberg, Feb 23, 2008
  8. 07/10 GitIndex: Get access to raw name and file modeRobin Rosenberg, Feb 23, 2008
  9. 08/10 TreeEntry: Accessors for full raw name and mode bitsRobin Rosenberg, Feb 23, 2008
  10. 09/10 Implement a Tree iteratorRobin Rosenberg, Feb 23, 2008
  11. 10/10 Rewritten IndexTreeWalkerRobin Rosenberg, Feb 23, 2008
  12. David WatsonMar 3, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.