aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-11-04 18:14:00 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-11-12 14:01:28 -0800
commit3e2b9b691ed30d53750cc08c2b89577b78e6d19a (patch)
treee66a5e0b60a6a723066a6855d1a4618333fe6862 /org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java
parentfaa0747cce9826137b3841661a5b745030fb55fe (diff)
downloadjgit-3e2b9b691ed30d53750cc08c2b89577b78e6d19a.tar.gz
jgit-3e2b9b691ed30d53750cc08c2b89577b78e6d19a.zip
Allow writing a NoteMap back to the repository
This is necessary to allow applications to wrap the note tree in a commit and update the note branch with the new state. Change-Id: Idbd7ead4a1b16ae2b64a30a4a01a29cfed548cdf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java
index 20fd3a88ad..6a2d44bca9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NonNoteEntry.java
@@ -68,4 +68,33 @@ class NonNoteEntry extends ObjectId {
void format(TreeFormatter fmt) {
fmt.append(name, mode, this);
}
+
+ int treeEntrySize() {
+ return TreeFormatter.entrySize(mode, name.length);
+ }
+
+ int pathCompare(byte[] bBuf, int bPos, int bLen, FileMode bMode) {
+ return pathCompare(name, 0, name.length, mode, //
+ bBuf, bPos, bLen, bMode);
+ }
+
+ private static int pathCompare(final byte[] aBuf, int aPos, final int aEnd,
+ final FileMode aMode, final byte[] bBuf, int bPos, final int bEnd,
+ final FileMode bMode) {
+ while (aPos < aEnd && bPos < bEnd) {
+ int cmp = (aBuf[aPos++] & 0xff) - (bBuf[bPos++] & 0xff);
+ if (cmp != 0)
+ return cmp;
+ }
+
+ if (aPos < aEnd)
+ return (aBuf[aPos] & 0xff) - lastPathChar(bMode);
+ if (bPos < bEnd)
+ return lastPathChar(aMode) - (bBuf[bPos] & 0xff);
+ return 0;
+ }
+
+ private static int lastPathChar(final FileMode mode) {
+ return FileMode.TREE.equals(mode.getBits()) ? '/' : '\0';
+ }
}