From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
Marek Zawirski <marek.zawirski@gmail.com>,
Florian Koeberle <florianskarten@web.de>,
Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [JGIT PATCH 3/4] Added a method to get the non-relative name from the tree walker
Date: Tue, 24 Jun 2008 23:36:31 +0200 [thread overview]
Message-ID: <1214343392-5341-4-git-send-email-robin.rosenberg@dewire.com> (raw)
In-Reply-To: <1214343392-5341-3-git-send-email-robin.rosenberg@dewire.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/treewalk/TreeWalk.java | 21 ++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index 42f8b25..a5eb4d9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -499,6 +499,17 @@ public class TreeWalk {
}
/**
+ * Get the current entry's name.
+ * <p>
+ *
+ * @return name of the current entry only.
+ * @see #getPathString()
+ */
+ public String getName() {
+ return nameOf(currentHead);
+ }
+
+ /**
* Test if the supplied path matches the current entry's path.
* <p>
* This method tests that the supplied path is exactly equal to the current
@@ -659,4 +670,14 @@ public class TreeWalk {
+ Constants.CHARACTER_ENCODING, uee);
}
}
+
+ private static String nameOf(final AbstractTreeIterator t) {
+ try {
+ return new String(t.path, t.pathOffset, t.pathLen - t.pathOffset,
+ Constants.CHARACTER_ENCODING);
+ } catch (UnsupportedEncodingException uee) {
+ throw new RuntimeException("JVM doesn't support "
+ + Constants.CHARACTER_ENCODING, uee);
+ }
+ }
}
--
1.5.5.1.178.g1f811
next prev parent reply other threads:[~2008-06-24 22:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080622233525.GJ11793@spearce.org>
2008-06-24 21:20 ` [JGIT PATCH 1/4] LsTree: Do not use the default first empty tree in the walker Robin Rosenberg
2008-06-24 21:20 ` [JGIT PATCH 2/4] Create a fnmatch-style pattern TreeFilter Robin Rosenberg
2008-06-24 21:20 ` [JGIT PATCH 3/4] Added a method to get the non-relative name from the tree walker Robin Rosenberg
2008-06-24 21:20 ` [JGIT PATCH 4/4] LsTree: Enable pattern matching in LsTree Robin Rosenberg
2008-06-24 21:36 ` oops, resend Robin Rosenberg
2008-06-24 21:36 ` [JGIT PATCH 1/4] LsTree: Do not use the default first empty tree in the walker Robin Rosenberg
2008-06-24 21:36 ` [JGIT PATCH 2/4] Create a fnmatch-style pattern TreeFilter Robin Rosenberg
2008-06-24 21:36 ` Robin Rosenberg [this message]
2008-06-24 21:36 ` [JGIT PATCH 4/4] LsTree: Enable pattern matching in LsTree Robin Rosenberg
2008-06-25 4:09 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1214343392-5341-4-git-send-email-robin.rosenberg@dewire.com \
--to=robin.rosenberg@dewire.com \
--cc=florianskarten@web.de \
--cc=git@vger.kernel.org \
--cc=marek.zawirski@gmail.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).