diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-05-08 17:13:25 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2010-05-08 17:13:25 -0400 |
commit | 0df679aea175aaba322416e586535ac877eba9a8 (patch) | |
tree | 5d1c277d6d9efc77996254fe1ef3feffdb66fc56 /org.eclipse.jgit | |
parent | 0f2d50b6b6c5b2575cfd81b3f0f7ad9ef799eaa9 (diff) | |
parent | a496410df9d9d2ff72c662d229329cae302a0edc (diff) | |
download | jgit-0df679aea175aaba322416e586535ac877eba9a8.tar.gz jgit-0df679aea175aaba322416e586535ac877eba9a8.zip |
Merge "A stages field and getter for GitIndex entry introduced"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java index 4ae24f5e2e..bba18408c8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitIndex.java @@ -244,7 +244,11 @@ public class GitIndex { entries.clear(); for (int i = 0; i < header.entries; ++i) { Entry entry = new Entry(buffer); + final GitIndex.Entry existing = entries.get(entry.name); entries.put(entry.name, entry); + if (existing != null) { + entry.stages |= existing.stages; + } } lastCacheTime = cacheFile.lastModified(); } finally { @@ -374,6 +378,8 @@ public class GitIndex { private byte[] name; + private int stages; + Entry(byte[] key, File f, int stage) throws IOException { ctime = f.lastModified() * 1000000L; @@ -391,6 +397,7 @@ public class GitIndex { sha1 = writer.writeBlob(f); name = key; flags = (short) ((stage << 12) | name.length); // TODO: fix flags + stages = (1 >> getStage()); } Entry(byte[] key, File f, int stage, byte[] newContent) @@ -410,6 +417,7 @@ public class GitIndex { sha1 = writer.writeBlob(newContent); name = key; flags = (short) ((stage << 12) | name.length); // TODO: fix flags + stages = (1 >> getStage()); } Entry(TreeEntry f, int stage) { @@ -429,6 +437,7 @@ public class GitIndex { sha1 = f.getId(); name = Constants.encode(f.getFullName()); flags = (short) ((stage << 12) | name.length); // TODO: fix flags + stages = (1 >> getStage()); } Entry(ByteBuffer b) { @@ -445,6 +454,7 @@ public class GitIndex { b.get(sha1bytes); sha1 = ObjectId.fromRaw(sha1bytes); flags = b.getShort(); + stages = (1 << getStage()); name = new byte[flags & 0xFFF]; b.get(name); b @@ -643,6 +653,19 @@ public class GitIndex { return false; } + /** + * Returns the stages in which the entry's file is recorded in the index. + * The stages are bit-encoded: bit N is set if the file is present + * in stage N. In particular, the N-th bit will be set if this entry + * itself is in stage N (see getStage()). + * + * @return flags denoting stages + * @see #getStage() + */ + public int getStages() { + return stages; + } + // for testing void forceRecheck() { mtime = -1; |