/**
* Execute the command line.
- *
+ *
* @param argv
* arguments.
*/
* index larger than the default BufferedInputStream buffer size. This made
* the DirCache unable to read the extensions when index size exceeded the
* buffer size (in some cases at least).
- *
+ *
* @throws CorruptObjectException
* @throws IOException
*/
public void testModified() throws IOException {
GitIndex index = new GitIndex(db);
-
-
+
+
index.add(trash, writeTrashFile("file2", "file2"));
index.add(trash, writeTrashFile("dir/file3", "dir/file3"));
-
+
writeTrashFile("dir/file3", "changed");
Tree tree = new Tree(db);
private ArrayList<String> treeOnlyEntriesVisited = new ArrayList<String>();
private ArrayList<String> bothVisited = new ArrayList<String>();
private ArrayList<String> indexOnlyEntriesVisited = new ArrayList<String>();
-
+
private class TestIndexTreeVisitor extends AbstractIndexTreeVisitor {
public void visitEntry(TreeEntry treeEntry, Entry indexEntry, File file) {
if (treeEntry == null)
/*
* Need to think about what I really need to be able to do....
- *
+ *
* 1) Visit all entries in index and tree
* 2) Get all directories that exist in the index, but not in the tree
* -- I'm pretty sure that I don't need to do the other way around
- * because I already
+ * because I already
*/
-
+
public void testTreeOnlyOneLevel() throws IOException {
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
tree.addFile("bar");
new IndexTreeWalker(index, tree, trash, new TestIndexTreeVisitor()).walk();
-
+
assertTrue(treeOnlyEntriesVisited.get(0).equals("bar"));
assertTrue(treeOnlyEntriesVisited.get(1).equals("foo"));
}
-
+
public void testIndexOnlyOneLevel() throws IOException {
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
index.add(trash, writeTrashFile("foo", "foo"));
index.add(trash, writeTrashFile("bar", "bar"));
new IndexTreeWalker(index, tree, trash, new TestIndexTreeVisitor()).walk();
-
+
assertTrue(indexOnlyEntriesVisited.get(0).equals("bar"));
assertTrue(indexOnlyEntriesVisited.get(1).equals("foo"));
}
-
+
public void testBoth() throws IOException {
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
tree.addFile("b/b");
index.add(trash, writeTrashFile("c", "c"));
tree.addFile("c");
-
+
new IndexTreeWalker(index, tree, trash, new TestIndexTreeVisitor()).walk();
assertTrue(indexOnlyEntriesVisited.contains("a"));
assertTrue(treeOnlyEntriesVisited.contains("b/b"));
assertTrue(bothVisited.contains("c"));
-
+
}
-
+
public void testIndexOnlySubDirs() throws IOException {
GitIndex index = new GitIndex(db);
Tree tree = new Tree(db);
index.add(trash, writeTrashFile("foo/bar/baz", "foobar"));
index.add(trash, writeTrashFile("asdf", "asdf"));
new IndexTreeWalker(index, tree, trash, new TestIndexTreeVisitor()).walk();
-
+
assertEquals("asdf", indexOnlyEntriesVisited.get(0));
assertEquals("foo/bar/baz", indexOnlyEntriesVisited.get(1));
}
-
+
public void testLeavingTree() throws IOException {
GitIndex index = new GitIndex(db);
index.add(trash, writeTrashFile("foo/bar", "foo/bar"));
index.add(trash, writeTrashFile("foobar", "foobar"));
-
+
new IndexTreeWalker(index, db.mapTree(index.writeTree()), trash, new AbstractIndexTreeVisitor() {
@Override
public void visitEntry(TreeEntry entry, Entry indexEntry, File f) {
if (entry == null || indexEntry == null)
fail();
}
-
+
@Override
public void finishVisitTree(Tree tree, int i, String curDir)
throws IOException {
if (i == 0)
fail();
}
-
+
}).walk();
}
}
/**
* Return file with appropriate index version for prepared pack.
- *
+ *
* @return file with index
*/
public abstract File getFileForPack34be9032();
/**
* Return file with appropriate index version for prepared pack.
- *
+ *
* @return file with index
*/
public abstract File getFileForPackdf2982f28();
import org.eclipse.jgit.errors.CheckoutConflictException;
public class ReadTreeTest extends RepositoryTestCase {
-
+
private Tree theHead;
private Tree theMerge;
private GitIndex theIndex;
// Rule 0 is left out for obvious reasons :)
public void testRules1thru3_NoIndexEntry() throws IOException {
GitIndex index = new GitIndex(db);
-
+
Tree head = new Tree(db);
FileTreeEntry headFile = head.addFile("foo");
ObjectId objectId = ObjectId.fromString("ba78e065e2c261d4f7b8f42107588051e87e18e9");
headFile.setId(objectId);
Tree merge = new Tree(db);
-
+
WorkDirCheckout readTree = new WorkDirCheckout(db, trash, head, index, merge);
readTree.prescanTwoTrees();
-
+
assertTrue(readTree.removed.contains("foo"));
-
+
readTree = new WorkDirCheckout(db, trash, merge, index, head);
readTree.prescanTwoTrees();
-
+
assertEquals(objectId, readTree.updated.get("foo"));
-
+
ObjectId anotherId = ObjectId.fromString("ba78e065e2c261d4f7b8f42107588051e87e18ee");
merge.addFile("foo").setId(anotherId);
-
+
readTree = new WorkDirCheckout(db, trash, head, index, merge);
readTree.prescanTwoTrees();
-
+
assertEquals(anotherId, readTree.updated.get("foo"));
}
- void setupCase(HashMap<String, String> headEntries,
- HashMap<String, String> mergeEntries,
+ void setupCase(HashMap<String, String> headEntries,
+ HashMap<String, String> mergeEntries,
HashMap<String, String> indexEntries) throws IOException {
theHead = buildTree(headEntries);
theMerge = buildTree(mergeEntries);
theIndex = buildIndex(indexEntries);
}
-
+
private GitIndex buildIndex(HashMap<String, String> indexEntries) throws IOException {
GitIndex index = new GitIndex(db);
-
+
if (indexEntries == null)
return index;
for (java.util.Map.Entry<String,String> e : indexEntries.entrySet()) {
index.add(trash, writeTrashFile(e.getKey(), e.getValue())).forceRecheck();
}
-
+
return index;
}
private Tree buildTree(HashMap<String, String> headEntries) throws IOException {
Tree tree = new Tree(db);
-
- if (headEntries == null)
+
+ if (headEntries == null)
return tree;
for (java.util.Map.Entry<String,String> e : headEntries.entrySet()) {
tree.addFile(e.getKey()).setId(genSha1(e.getValue()));
}
-
+
return tree;
}
-
+
ObjectId genSha1(String data) {
InputStream is = new ByteArrayInputStream(data.getBytes());
ObjectWriter objectWriter = new ObjectWriter(db);
}
return null;
}
-
+
private WorkDirCheckout go() throws IOException {
theReadTree = new WorkDirCheckout(db, trash, theHead, theIndex, theMerge);
theReadTree.prescanTwoTrees();
idxMap.put("foo", "foo");
setupCase(null, null, idxMap);
theReadTree = go();
-
+
assertTrue(theReadTree.updated.isEmpty());
assertTrue(theReadTree.removed.isEmpty());
assertTrue(theReadTree.conflicts.isEmpty());
-
+
// rules 6 and 7
idxMap = new HashMap<String, String>();
idxMap.put("foo", "foo");
theReadTree = go();
assertAllEmpty();
-
+
// rules 8 and 9
HashMap<String, String> mergeMap;
mergeMap = new HashMap<String, String>();
-
+
mergeMap.put("foo", "merge");
setupCase(null, mergeMap, idxMap);
go();
-
+
assertTrue(theReadTree.updated.isEmpty());
assertTrue(theReadTree.removed.isEmpty());
assertTrue(theReadTree.conflicts.contains("foo"));
-
+
// rule 10
-
+
HashMap<String, String> headMap = new HashMap<String, String>();
headMap.put("foo", "foo");
setupCase(headMap, null, idxMap);
go();
-
+
assertTrue(theReadTree.removed.contains("foo"));
assertTrue(theReadTree.updated.isEmpty());
assertTrue(theReadTree.conflicts.isEmpty());
-
+
// rule 11
setupCase(headMap, null, idxMap);
new File(trash, "foo").delete();
writeTrashFile("foo", "bar");
theIndex.getMembers()[0].forceRecheck();
go();
-
+
assertTrue(theReadTree.removed.isEmpty());
assertTrue(theReadTree.updated.isEmpty());
assertTrue(theReadTree.conflicts.contains("foo"));
-
+
// rule 12 & 13
headMap.put("foo", "head");
setupCase(headMap, null, idxMap);
go();
-
+
assertTrue(theReadTree.removed.isEmpty());
assertTrue(theReadTree.updated.isEmpty());
assertTrue(theReadTree.conflicts.contains("foo"));
-
+
// rules 14 & 15
setupCase(headMap, headMap, idxMap);
go();
-
+
assertAllEmpty();
-
+
// rules 16 & 17
setupCase(headMap, mergeMap, idxMap); go();
assertTrue(theReadTree.conflicts.contains("foo"));
-
+
// rules 18 & 19
setupCase(headMap, idxMap, idxMap); go();
assertAllEmpty();
-
+
// rule 20
setupCase(idxMap, mergeMap, idxMap); go();
assertTrue(theReadTree.updated.containsKey("foo"));
-
+
// rules 21
- setupCase(idxMap, mergeMap, idxMap);
+ setupCase(idxMap, mergeMap, idxMap);
new File(trash, "foo").delete();
writeTrashFile("foo", "bar");
theIndex.getMembers()[0].forceRecheck();
assertTrue(theReadTree.updated.isEmpty());
assertTrue(theReadTree.conflicts.isEmpty());
}
-
+
public void testDirectoryFileSimple() throws IOException {
theIndex = new GitIndex(db);
theIndex.add(trash, writeTrashFile("DF", "DF"));
Tree treeDF = db.mapTree(theIndex.writeTree());
-
+
recursiveDelete(new File(trash, "DF"));
theIndex = new GitIndex(db);
theIndex.add(trash, writeTrashFile("DF/DF", "DF/DF"));
Tree treeDFDF = db.mapTree(theIndex.writeTree());
-
+
theIndex = new GitIndex(db);
recursiveDelete(new File(trash, "DF"));
-
+
theIndex.add(trash, writeTrashFile("DF", "DF"));
theReadTree = new WorkDirCheckout(db, trash, treeDF, theIndex, treeDFDF);
theReadTree.prescanTwoTrees();
-
+
assertTrue(theReadTree.removed.contains("DF"));
assertTrue(theReadTree.updated.containsKey("DF/DF"));
-
+
recursiveDelete(new File(trash, "DF"));
theIndex = new GitIndex(db);
theIndex.add(trash, writeTrashFile("DF/DF", "DF/DF"));
-
+
theReadTree = new WorkDirCheckout(db, trash, treeDFDF, theIndex, treeDF);
theReadTree.prescanTwoTrees();
assertTrue(theReadTree.removed.contains("DF/DF"));
assertTrue(theReadTree.updated.containsKey("DF"));
}
-
+
/*
* Directory/File Conflict cases:
* It's entirely possible that in practice a number of these may be equivalent
* that's all I care about. These are basically reverse-engineered from
* what git currently does. If there are tests for these in git, it's kind of
* hard to track them all down...
- *
+ *
* H I M Clean H==M H==I I==M Result
* ------------------------------------------------------------------
*1 D D F Y N Y N Update
*8 F D F N Y N N Conflict
*9 F D F Y N N N Update
*10 F D D N N Y Keep
- *11 F D D N N N Conflict
+ *11 F D D N N N Conflict
*12 F F D Y N Y N Update
*13 F F D N N Y N Conflict
*14 F F D N N N Conflict
*18 F 0 D Update
*19 D 0 F Update
*/
-
+
public void testDirectoryFileConflicts_1() throws Exception {
// 1
doit(mk("DF/DF"), mk("DF"), mk("DF/DF"));
writeTrashFile("DF/DF", "different");
go();
assertConflict("DF/DF");
-
+
}
public void testDirectoryFileConflicts_3() throws Exception {
doit(mk("DF/DF"), mkmap("DF/DF", "foo"), mk("DF"));
assertUpdated("DF/DF");
assertRemoved("DF");
-
+
}
public void testDirectoryFileConflicts_5() throws Exception {
// 5
doit(mk("DF/DF"), mk("DF"), mk("DF"));
assertRemoved("DF/DF");
-
+
}
public void testDirectoryFileConflicts_6() throws Exception {
go();
assertRemoved("DF/DF/DF/DF/DF");
assertUpdated("DF/DF");
-
+
cleanUpDF();
setupCase(mk("DF/DF"), mk("DF/DF"), mk("DF/DF/DF/DF/DF"));
writeTrashFile("DF/DF/DF/DF/DF", "diff");
cleanUpDF();
doit(mk("DF"), mk("DF/DF"), mk("DF/DF"));
assertNoConflicts();
-
+
}
public void testDirectoryFileConflicts_11() throws Exception {
setUp();
recursiveDelete(new File(trash, "DF"));
}
-
+
private void assertConflict(String s) {
assertTrue(theReadTree.conflicts.contains(s));
}
-
+
private void assertUpdated(String s) {
assertTrue(theReadTree.updated.containsKey(s));
}
-
+
private void assertRemoved(String s) {
assertTrue(theReadTree.removed.contains(s));
}
-
+
private void assertNoConflicts() {
assertTrue(theReadTree.conflicts.isEmpty());
}
setupCase(h, m, i);
go();
}
-
+
private static HashMap<String, String> mk(String a) {
return mkmap(a, a);
}
-
+
private static HashMap<String, String> mkmap(String... args) {
- if ((args.length % 2) > 0)
+ if ((args.length % 2) > 0)
throw new IllegalArgumentException("needs to be pairs");
-
+
HashMap<String, String> map = new HashMap<String, String>();
for (int i = 0; i < args.length; i += 2) {
map.put(args[i], args[i+1]);
}
-
+
return map;
}
-
- public void testUntrackedConflicts() throws IOException {
+
+ public void testUntrackedConflicts() throws IOException {
setupCase(null, mk("foo"), null);
writeTrashFile("foo", "foo");
go();
-
+
assertConflict("foo");
-
+
recursiveDelete(new File(trash, "foo"));
setupCase(null, mk("foo"), null);
writeTrashFile("foo/bar/baz", "");
assertConflict("foo/bar/baz");
assertConflict("foo/blahblah");
-
+
recursiveDelete(new File(trash, "foo"));
-
- setupCase(mkmap("foo/bar", "", "foo/baz", ""),
+
+ setupCase(mkmap("foo/bar", "", "foo/baz", ""),
mk("foo"), mkmap("foo/bar", "", "foo/baz", ""));
assertTrue(new File(trash, "foo/bar").exists());
go();
-
+
assertNoConflicts();
}
theReadTree = new WorkDirCheckout(db, trash, theHead, theIndex, theMerge);
theReadTree.checkout();
}
-
+
public void testCheckoutOutChanges() throws IOException {
setupCase(mk("foo"), mk("foo/bar"), mk("foo"));
checkout();
-
+
assertFalse(new File(trash, "foo").isFile());
assertTrue(new File(trash, "foo/bar").isFile());
recursiveDelete(new File(trash, "foo"));
setupCase(mk("foo/bar"), mk("foo"), mk("foo/bar"));
checkout();
-
+
assertFalse(new File(trash, "foo/bar").isFile());
assertTrue(new File(trash, "foo").isFile());
-
+
setupCase(mk("foo"), mkmap("foo", "qux"), mkmap("foo", "bar"));
-
+
try {
checkout();
fail("did not throw exception");
t.setTag("test020b");
t.setObjId(ObjectId.fromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
t.tag();
-
+
Tag mapTag = db.mapTag("test020b");
assertEquals("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", mapTag.getObjId().name());
-
+
// We do not repeat the plain tag test for other object types
}
assertEquals(new PersonIdent(jauthor, 1154236443000L, -4 * 60), mapTag.getAuthor());
assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.getObjId().name());
}
-
+
public void test023_createCommitNonAnullii() throws IOException {
final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
final Tree almostEmptyTree = new Tree(db);
ObjectId cid = new ObjectWriter(db).writeCommit(commit);
assertEquals("2979b39d385014b33287054b87f77bcb3ecb5ebf", cid.name());
}
-
+
public void test025_packedRefs() throws IOException {
test020_createBlobTag();
test021_createTreeTag();
assertEquals(c2.getCommitId(), rm4.getParentIds()[1]);
assertEquals(c3.getCommitId(), rm4.getParentIds()[2]);
}
-
+
public void test027_UnpackedRefHigherPriorityThanPacked() throws IOException {
- PrintWriter writer = new PrintWriter(new FileWriter(new File(db.getDirectory(), "refs/heads/a")));
+ PrintWriter writer = new PrintWriter(new FileWriter(new File(db.getDirectory(), "refs/heads/a")));
String unpackedId = "7f822839a2fe9760f386cbbbcb3f92c5fe81def7";
writer.print(unpackedId);
writer.print('\n');
ObjectId id = index.writeTree();
assertEquals("c696abc3ab8e091c665f49d00eb8919690b3aec3", id.name());
-
+
writeTrashFile("a/b", "data:a/b");
index.add(trash, new File(trash, "a/b"));
/**
* one file
- *
+ *
* @throws IOException
*/
public void testSimpleF1() throws IOException {
/**
* two files
- *
+ *
* @throws IOException
*/
public void testSimpleF2() throws IOException {
/**
* Empty tree
- *
+ *
* @throws IOException
*/
public void testSimpleT() throws IOException {
TreeIterator i = makeIterator(tree);
assertFalse(i.hasNext());
}
-
+
public void testTricky() throws IOException {
Tree tree = new Tree(db);
tree.addFile("a.b");
/**
* one file
- *
+ *
* @throws IOException
*/
public void testSimpleF1() throws IOException {
/**
* two files
- *
+ *
* @throws IOException
*/
public void testSimpleF2() throws IOException {
/**
* Empty tree
- *
+ *
* @throws IOException
*/
public void testSimpleT() throws IOException {
assertEquals("", i.next().getFullName());
assertFalse(i.hasNext());
}
-
+
public void testTricky() throws IOException {
Tree tree = new Tree(db);
tree.addFile("a.b");
/**
* one file
- *
+ *
* @throws IOException
*/
public void testSimpleF1() throws IOException {
/**
* two files
- *
+ *
* @throws IOException
*/
public void testSimpleF2() throws IOException {
/**
* Empty tree
- *
+ *
* @throws IOException
*/
public void testSimpleT() throws IOException {
assertEquals("a", i.next().getFullName());
assertFalse(i.hasNext());
}
-
+
public void testTricky() throws IOException {
Tree tree = new Tree(db);
tree.addFile("a.b");
/**
* Incremental bundle test
- *
+ *
* @throws Exception
*/
public void testWrite1() throws Exception {
return arcHeight * 3 + textw;
}
-}
\ No newline at end of file
+}
/**
* Add a cached authentication for future use.
- *
+ *
* @param ca
* the information we should remember.
*/
/**
* Create a new cached authentication.
- *
+ *
* @param aHost
* system this is for.
* @param aPort
/**
* Get the commit list this pane renders from.
- *
+ *
* @return the list the caller must populate.
*/
public PlotCommitList getCommitList() {
hash = (hash << 5) ^ (raw[ptr] & 0xff);
return hash;
}
-}
\ No newline at end of file
+}
* @return true if the elements are equal; false if they are not equal.
*/
public boolean equals(int thisIdx, Sequence other, int otherIdx);
-}
\ No newline at end of file
+}
public CheckoutConflictException(String file) {
super("Checkout conflict with file: " + file);
}
-
+
/**
* Construct a CheckoutConflictException for the specified set of files
*
private static String buildList(String[] files) {
StringBuilder builder = new StringBuilder();
- for (String f : files) {
+ for (String f : files) {
builder.append("\n");
builder.append(f);
}
/**
* Constructs an exception detailing many potential reasons for failure.
- *
+ *
* @param why
* Two or more exceptions that may have been the problem.
*/
/**
* Get the complete list of reasons why this failure happened.
- *
+ *
* @return unmodifiable collection of all possible reasons.
*/
public List<Throwable> getAllCauses() {
/**
* Construct a NotSupportedException for some issue JGit cannot yet handle.
- *
+ *
* @param s
* message describing the issue
* @param why
/**
* Constructs an PackProtocolException with the specified detail message.
- *
+ *
* @param s
* message
*/
/**
* Constructs an PackProtocolException with the specified detail message.
- *
+ *
* @param s
* message
* @param cause
/**
* Construct a RevisionSyntaxException indicating a syntax problem with a
* revision (or object) string.
- *
+ *
* @param revstr The problematic revision string
*/
public RevisionSyntaxException(String revstr) {
this.revstr = revstr;
}
-
+
/**
* Construct a RevisionSyntaxException indicating a syntax problem with a
* revision (or object) string.
/**
* Stops the driver loop of walker and finish with current results.
- *
+ *
* @see org.eclipse.jgit.revwalk.filter.RevFilter
*/
public class StopWalkException extends RuntimeException {
/**
* Constructs an TransportException with the specified detail message.
- *
+ *
* @param s
* message
*/
/**
* Constructs an TransportException with the specified detail message.
- *
+ *
* @param s
* message
* @param cause
/**
* Compare to object identifier byte sequences for equality.
- *
+ *
* @param firstObjectId
* the first identifier to compare. Must not be null.
* @param secondObjectId
/**
* For ObjectIdMap
- *
+ *
* @return a discriminator usable for a fan-out style map
*/
public final int getFirstByte() {
/**
* Compare this ObjectId to another and obtain a sort ordering.
- *
+ *
* @param other
* the other id to compare to. Must not be null.
* @return < 0 if this id comes before other; 0 if this id is equal to
/**
* Determine if this ObjectId has exactly the same value as another.
- *
+ *
* @param other
* the other id to compare to. May be null.
* @return true only if both ObjectIds have identical bits.
/**
* Copy this ObjectId to an output writer in raw binary.
- *
+ *
* @param w
* the buffer to copy to. Must be in big endian order.
*/
/**
* Copy this ObjectId to a byte array.
- *
+ *
* @param b
* the buffer to copy to.
* @param o
/**
* Copy this ObjectId to an output writer in raw binary.
- *
+ *
* @param w
* the stream to write to.
* @throws IOException
/**
* Copy this ObjectId to an output writer in hex format.
- *
+ *
* @param w
* the stream to copy to.
* @throws IOException
/**
* Copy this ObjectId to an output writer in hex format.
- *
+ *
* @param w
* the stream to copy to.
* @throws IOException
/**
* Copy this ObjectId to an output writer in hex format.
- *
+ *
* @param tmp
* temporary char array to buffer construct into before writing.
* Must be at least large enough to hold 2 digits for each byte
* This method is useful to shed any additional memory that may be tied to
* the subclass, yet retain the unique identity of the object id for future
* lookups within maps and repositories.
- *
+ *
* @return an immutable copy, using the smallest memory footprint possible.
*/
public final ObjectId copy() {
* See {@link #copy()} if <code>this</code> is a possibly subclassed (but
* immutable) identity and the application needs a lightweight identity
* <i>only</i> reference.
- *
+ *
* @return an immutable copy. May be <code>this</code> if this is already
* an immutable instance.
*/
/**
* Copy bytes from the window to a caller supplied buffer.
- *
+ *
* @param pos
* offset within the file to start copying from.
* @param dstbuf
/**
* Copy bytes from the window to a caller supplied buffer.
- *
+ *
* @param pos
* offset within the window to start copying from.
* @param dstbuf
/**
* Pump bytes into the supplied inflater as input.
- *
+ *
* @param pos
* offset within the file to start supplying input from.
* @param dstbuf
/**
* Pump bytes into the supplied inflater as input.
- *
+ *
* @param pos
* offset within the window to start supplying input from.
* @param dstbuf
private ObjectId treeId;
private ObjectId[] parentIds;
-
+
private PersonIdent author;
private PersonIdent committer;
objdb = db;
parentIds = EMPTY_OBJECTID_LIST;
}
-
+
/**
* Create a commit associated with these parents and associate it with a
* repository.
* Indicates the associated object is a commit.
* <p>
* <b>This constant is fixed and is defined by the Git packfile format.</b>
- *
+ *
* @see #TYPE_COMMIT
*/
public static final int OBJ_COMMIT = 1;
* Indicates the associated object is a tree.
* <p>
* <b>This constant is fixed and is defined by the Git packfile format.</b>
- *
+ *
* @see #TYPE_BLOB
*/
public static final int OBJ_TREE = 2;
* Indicates the associated object is a blob.
* <p>
* <b>This constant is fixed and is defined by the Git packfile format.</b>
- *
+ *
* @see #TYPE_BLOB
*/
public static final int OBJ_BLOB = 3;
* Indicates the associated object is an annotated tag.
* <p>
* <b>This constant is fixed and is defined by the Git packfile format.</b>
- *
+ *
* @see #TYPE_TAG
*/
public static final int OBJ_TAG = 4;
* <b>This constant is fixed and is defined by the Git packfile format.</b>
*/
public static final byte[] PACK_SIGNATURE = { 'P', 'A', 'C', 'K' };
-
+
/** Native character encoding for commit messages, file names... */
public static final String CHARACTER_ENCODING = "UTF-8";
/**
* Create a new digest function for objects.
- *
+ *
* @return a new digest object.
* @throws RuntimeException
* this Java virtual machine does not support the required hash
/**
* Parse an encoded type string into a type constant.
- *
+ *
* @param id
* object id this type string came from; may be null if that is
* not known at the time the parse is occurring.
/**
* Convert an integer into its decimal representation.
- *
+ *
* @param s
* the integer to convert.
* @return a decimal representation of the input integer. The returned array
/**
* Convert a string to US-ASCII encoding.
- *
+ *
* @param s
* the string to convert. Must not contain any characters over
* 127 (outside of 7-bit ASCII).
public String toString() {
return getClass().getSimpleName() + "[" + getFile().getPath() + "]";
}
-}
\ No newline at end of file
+}
/**
* Convert a set of mode bits into a FileMode enumerated value.
- *
+ *
* @param bits
* the mode bits the caller has somehow obtained.
* @return the FileMode instance that represents the given bits.
/**
* Test a file mode for equality with this {@link FileMode} object.
- *
+ *
* @param modebits
* @return true if the mode bits represent the same mode as this object
*/
* indicate octal notation. This method is suitable for generation of a mode
* string within a GIT tree object.
* </p>
- *
+ *
* @param os
* stream to copy the mode to.
* @throws IOException
* Get the object type that should appear for this type of mode.
* <p>
* See the object type constants in {@link Constants}.
- *
+ *
* @return one of the well known object type constants.
*/
public int getObjectType() {
* @param f
* the file whose path shall be removed.
* @return true if such a path was found (and thus removed)
- * @throws IOException
+ * @throws IOException
*/
public boolean remove(File wd, File f) throws IOException {
byte[] key = makeKey(wd, f);
}
/**
- * Check if an entry's content is different from the cache,
- *
+ * Check if an entry's content is different from the cache,
+ *
* File status information is used and status is same we
* consider the file identical to the state in the working
* directory. Native git uses more stat fields than we
* have accessible in Java.
- *
+ *
* @param wd working directory to compare content with
* @return true if content is most likely different.
*/
}
/**
- * Check if an entry's content is different from the cache,
- *
+ * Check if an entry's content is different from the cache,
+ *
* File status information is used and status is same we
* consider the file identical to the state in the working
* directory. Native git uses more stat fields than we
* have accessible in Java.
- *
+ *
* @param wd working directory to compare content with
* @param forceContentCheck True if the actual file content
* should be checked if modification time differs.
- *
+ *
* @return true if content is most likely different.
*/
public boolean isModified(File wd, boolean forceContentCheck) {
}
}
}
-
+
/**
* Add tree entry to index
* @param te tree entry
checkoutEntry(wd, e);
}
}
-
+
/**
* Check out content of the specified index entry
*
* Small beware: Unaccounted for are unmerged entries. You may want
* to abort if members with stage != 0 are found if you are doing
* any updating operations. All stages will be found after one another
- * here later. Currently only one stage per name is returned.
+ * here later. Currently only one stage per name is returned.
*
* @return The index entries sorted
*/
public class IndexDiff {
private GitIndex index;
private Tree tree;
-
+
/**
* Construct an indexdiff for diffing the workdir against
* the index.
this.tree = tree;
this.index = index;
}
-
+
boolean anyChanges = false;
-
+
/**
* Run the diff operation. Until this is called, all lists will be empty
* @return if anything is different between index, tree, and workdir
anyChanges = true;
}
}
-
+
if (indexEntry != null) {
if (!file.exists()) {
missing.add(indexEntry.getName());
}
}
}).walk();
-
+
return anyChanges;
}
public HashSet<String> getMissing() {
return missing;
}
-
+
/**
* @return list of files on modified on disk relative to the index
*/
* @throws IOException
*/
public void visitEntry(TreeEntry treeEntry, Entry indexEntry, File file) throws IOException;
-
+
/**
* Visit a blob, and corresponding tree nodes and associated index entry.
*
this.root = root;
this.visitor = visitor;
this.newTree = null;
-
+
threeTrees = false;
-
+
indexMembers = index.getMembers();
}
-
+
/**
* Construct a walker for the index and two trees.
*
this.newTree = newTree;
this.root = root;
this.visitor = visitor;
-
+
threeTrees = true;
-
+
indexMembers = index.getMembers();
}
Entry[] indexMembers;
int indexCounter = 0;
-
+
/**
* Actually walk the index tree
*
int cmpma = compare(m, a);
int cmpmi = compare(m, i);
int cmpai = compare(a, i);
-
+
TreeEntry pm = cmpma <= 0 && cmpmi <= 0 ? m : null;
TreeEntry pa = cmpma >= 0 && cmpai <= 0 ? a : null;
Entry pi = cmpmi >= 0 && cmpai >= 0 ? i : null;
static boolean lt(TreeEntry h, Entry i) {
return compare(h, i) < 0;
}
-
+
static boolean lt(Entry i, TreeEntry t) {
return compare(t, i) > 0;
}
static boolean lt(TreeEntry h, TreeEntry m) {
return compare(h, m) < 0;
}
-
+
static boolean eq(TreeEntry t1, TreeEntry t2) {
return compare(t1, t2) == 0;
}
-
+
static boolean eq(TreeEntry t1, Entry e) {
return compare(t1, e) == 0;
}
return 1;
if (i == null)
return -1;
- return Tree.compareNames(t.getFullNameUTF8(), i.getNameUTF8(), TreeEntry.lastChar(t), TreeEntry.lastChar(i));
+ return Tree.compareNames(t.getFullNameUTF8(), i.getNameUTF8(), TreeEntry.lastChar(t), TreeEntry.lastChar(i));
}
-
+
static int compare(TreeEntry t1, TreeEntry t2) {
if (t1 != null && t1.getParent() == null && t2 != null && t2.getParent() == null)
return 0;
return -1;
return Tree.compareNames(t1.getFullNameUTF8(), t2.getFullNameUTF8(), TreeEntry.lastChar(t1), TreeEntry.lastChar(t2));
}
-
+
}
* <p>
* Inflaters obtained through this cache should be returned (if possible) by
* {@link #release(Inflater)} to avoid garbage collection and reallocation.
- *
+ *
* @return an available inflater. Never null.
*/
public static Inflater get() {
/**
* Release an inflater previously obtained from this cache.
- *
+ *
* @param i
* the inflater to return. May be null, in which case this method
* does nothing.
/**
* Create a new lock for any file.
- *
+ *
* @param f
* the file that will be locked.
*/
/**
* Try to establish the lock.
- *
+ *
* @return true if the lock is now held by the caller; false if it is held
* by someone else.
* @throws IOException
/**
* Try to establish the lock for appending.
- *
+ *
* @return true if the lock is now held by the caller; false if it is held
* by someone else.
* @throws IOException
* <p>
* This method does nothing if the current file does not exist, or exists
* but is empty.
- *
+ *
* @throws IOException
* the temporary file could not be written, or a read error
* occurred while reading from the current file. The lock is
/**
* Write an ObjectId and LF to the temporary file.
- *
+ *
* @param id
* the id to store in the file. The id will be written in hex,
* followed by a sole LF.
/**
* Write arbitrary data to the temporary file.
- *
+ *
* @param content
* the bytes to store in the temporary file. No additional bytes
* are added, so if the file must end with an LF it must appear
* The stream may only be accessed once, and only after {@link #lock()} has
* been successfully invoked and returned true. Callers must close the
* stream prior to calling {@link #commit()} to commit the change.
- *
+ *
* @return a stream to write to the new file. The stream is unbuffered.
*/
public OutputStream getOutputStream() {
/**
* Request that {@link #commit()} remember modification time.
- *
+ *
* @param on
* true if the commit method must remember the modification time.
*/
* Commit this change and release the lock.
* <p>
* If this method fails (returns false) the lock is still released.
- *
+ *
* @return true if the commit was successful and the file contains the new
* data; false if the commit failed and the file remains with the
* old data.
/**
* Get the modification time of the output file when it was committed.
- *
+ *
* @return modification time of the lock file right before we committed it.
*/
public long getCommitLastModified() {
/**
* Copying constructor.
- *
+ *
* @param src
* original entry, to copy id from
*/
/**
* Convert an ObjectId from raw binary representation.
- *
+ *
* @param bs
* the raw byte buffer to read from. At least 20 bytes must be
* available within this byte array.
/**
* Convert an ObjectId from raw binary representation.
- *
+ *
* @param bs
* the raw byte buffer to read from. At least 20 bytes after p
* must be available within this byte array.
/**
* Convert an ObjectId from binary representation expressed in integers.
- *
+ *
* @param ints
* the raw int buffer to read from. At least 5 integers must be
* available within this integers array.
/**
* Convert an ObjectId from binary representation expressed in integers.
- *
+ *
* @param ints
* the raw int buffer to read from. At least 5 integers after p
* must be available within this integers array.
* @param p
* position to read the first integer of data from.
- *
+ *
*/
public void fromRaw(final int[] ints, final int p) {
w1 = ints[p];
/**
* Convert an ObjectId from hex characters (US-ASCII).
- *
+ *
* @param buf
* the US-ASCII buffer to read from. At least 40 bytes after
* offset must be available within this byte array.
/**
* Convert an ObjectId from hex characters.
- *
+ *
* @param str
* the string to read from. Must be 40 characters long.
*/
/**
* Get the special all-null ObjectId.
- *
+ *
* @return the all-null ObjectId, often used to stand-in for no object.
*/
public static final ObjectId zeroId() {
* Test a string of characters to verify it is a hex format.
* <p>
* If true the string can be parsed with {@link #fromString(String)}.
- *
+ *
* @param id
* the string to test.
* @return true if the string can converted into an ObjectId.
/**
* Convert an ObjectId into a hex string representation.
- *
+ *
* @param i
* the id to convert. May be null.
* @return the hex string conversion of this id's content.
/**
* Compare to object identifier byte sequences for equality.
- *
+ *
* @param firstBuffer
* the first buffer to compare against. Must have at least 20
* bytes from position ai through the end of the buffer.
/**
* Convert an ObjectId from raw binary representation.
- *
+ *
* @param bs
* the raw byte buffer to read from. At least 20 bytes must be
* available within this byte array.
/**
* Convert an ObjectId from raw binary representation.
- *
+ *
* @param bs
* the raw byte buffer to read from. At least 20 bytes after p
* must be available within this byte array.
/**
* Convert an ObjectId from hex characters (US-ASCII).
- *
+ *
* @param buf
* the US-ASCII buffer to read from. At least 40 bytes after
* offset must be available within this byte array.
/**
* Convert an ObjectId from hex characters.
- *
+ *
* @param str
* the string to read from. Must be 40 characters long.
* @return the converted object id.
* This constructor is mostly useful for subclasses who want to extend an
* ObjectId with more properties, but initialize from an existing ObjectId
* instance acquired by other means.
- *
+ *
* @param src
* another already parsed ObjectId to copy the value out of.
*/
* not reference equality and not <code>.equals(Object)</code> equality. This
* allows subclasses to override <code>equals</code> to supply their own
* extended semantics.
- *
+ *
* @param <V>
* type of subclass of ObjectId that will be stored in the map.
*/
/**
* Lookup an existing mapping.
- *
+ *
* @param toFind
* the object identifier to find.
* @return the instance mapped to toFind, or null if no mapping exists.
* An existing mapping for <b>must not</b> be in this map. Callers must
* first call {@link #get(AnyObjectId)} to verify there is no current
* mapping prior to adding a new mapping.
- *
+ *
* @param newValue
* the object to store.
* @param
* <p>
* Unlike {@link #getCachedBytes()} this method returns an array that might
* be modified by the caller.
- *
+ *
* @return the bytes of this object.
*/
public final byte[] getBytes() {
* saving on data copies between the internal cache and higher level code.
* Callers who receive this reference <b>must not</b> modify its contents.
* Changes (if made) will affect the cache but not the repository itself.
- *
+ *
* @return the cached bytes of this object. Do not modify it.
*/
public abstract byte[] getCachedBytes();
/**
* Construct a reader for an existing, pre-indexed packfile.
- *
+ *
* @param idxFile
* path of the <code>.idx</code> file listing the contents.
* @param packFile
* For performance reasons only the index file is searched; the main pack
* content is ignored entirely.
* </p>
- *
+ *
* @param id
* the object to look for. Must not be null.
* @return true if the object is in this pack; false otherwise.
/**
* Get an object from this pack.
- *
+ *
* @param curs
* temporary working space associated with the calling thread.
* @param id
* <p>
* Iterator returns objects in SHA-1 lexicographical order.
* </p>
- *
+ *
* @return iterator over entries of associated pack index
- *
+ *
* @see PackIndex#iterator()
*/
public Iterator<PackIndex.MutableEntry> iterator() {
/**
* Obtain the total number of objects available in this pack. This method
* relies on pack index, giving number of effectively available objects.
- *
+ *
* @return number of objects in index of this pack, likewise in this pack
* @throws IOException
* the index file cannot be loaded into memory.
* implementation for that format will be constructed and returned to the
* caller. The file may or may not be held open by the returned instance.
* </p>
- *
+ *
* @param idxFile
* existing pack .idx to read.
* @return access implementation for the requested file.
/**
* Determine if an object is contained within the pack file.
- *
+ *
* @param id
* the object to look for. Must not be null.
* @return true if the object is listed in this index; false otherwise.
* <p>
* Iterator returns objects in SHA-1 lexicographical order.
* </p>
- *
+ *
* @return iterator over pack index entries
*/
public abstract Iterator<MutableEntry> iterator();
/**
* Obtain the total number of objects described by this index.
- *
+ *
* @return number of objects in this index, and likewise in the associated
* pack that this index was generated from.
*/
/**
* Locate the file offset position for the requested object.
- *
+ *
* @param objId
* name of the object to locate within the pack.
* @return offset of the object's header and compressed content; -1 if the
/**
* Represent mutable entry of pack index consisting of object id and offset
* in pack (both mutable).
- *
+ *
*/
public static class MutableEntry {
final MutableObjectId idBuffer = new MutableObjectId();
/**
* Returns offset for this index object entry
- *
+ *
* @return offset of this object in a pack file
*/
public long getOffset() {
/**
* A combination of a person identity and time in Git.
- *
+ *
* Git combines Name + email + time + time zone to specify who wrote or
* committed something.
*/
* Creates new PersonIdent from config info in repository, with current time.
* This new PersonIdent gets the info from the default committer as available
* from the configuration.
- *
+ *
* @param repo
*/
public PersonIdent(final Repository repo) {
/**
* Copy a {@link PersonIdent}.
- *
+ *
* @param pi
* Original {@link PersonIdent}
*/
/**
* Construct a new {@link PersonIdent} with current time.
- *
+ *
* @param aName
* @param aEmailAddress
*/
/**
* Copy a PersonIdent, but alter the clone's time stamp
- *
+ *
* @param pi
* original {@link PersonIdent}
* @param when
/**
* Copy a {@link PersonIdent}, but alter the clone's time stamp
- *
+ *
* @param pi
* original {@link PersonIdent}
* @param aWhen
/**
* Construct a PersonIdent from simple data
- *
+ *
* @param aName
* @param aEmailAddress
* @param aWhen
/**
* Construct a {@link PersonIdent}
- *
+ *
* @param aName
* @param aEmailAddress
* @param aWhen
/**
* Copy a PersonIdent, but alter the clone's time stamp
- *
+ *
* @param pi
* original {@link PersonIdent}
* @param aWhen
/**
* Construct a PersonIdent from a string with full name, email, time time
* zone string. The input string must be valid.
- *
+ *
* @param in
* a Git internal format author/committer string.
*/
/**
* Format for Git storage.
- *
+ *
* @return a string in the git author format
*/
public String toExternalString() {
* Advise the monitor of the total number of subtasks.
* <p>
* This should be invoked at most once per progress monitor interface.
- *
+ *
* @param totalTasks
* the total number of tasks the caller will need to complete
* their processing.
/**
* Begin processing a single task.
- *
+ *
* @param title
* title to describe the task. Callers should publish these as
* stable string constants that implementations could match
* This is an incremental update; if invoked once per work unit the correct
* value for our argument is <code>1</code>, to indicate a single unit of
* work has been finished by the caller.
- *
+ *
* @param completed
* the number of work units completed since the last call.
*/
/**
* Check for user task cancellation.
- *
+ *
* @return true if the user asked the process to stop working.
*/
boolean isCancelled();
/**
* Create a new ref pairing.
- *
+ *
* @param st
* method used to store this ref.
* @param origName
/**
* Create a new ref pairing.
- *
+ *
* @param st
* method used to store this ref.
* @param refName
/**
* Create a new ref pairing.
- *
+ *
* @param st
* method used to store this ref.
* @param origName
/**
* Create a new ref pairing.
- *
+ *
* @param st
* method used to store this ref.
* @param refName
/**
* What this ref is called within the repository.
- *
+ *
* @return name of this ref.
*/
public String getName() {
/**
* Cached value of this ref.
- *
+ *
* @return the value of this ref at the last time we read it.
*/
public ObjectId getObjectId() {
/**
* Cached value of <code>ref^{}</code> (the ref peeled to commit).
- *
+ *
* @return if this ref is an annotated tag the id of the commit (or tree or
* blob) that the annotated tag refers to; null if this ref does not
* refer to an annotated tag.
/**
* Sorts the collection of refs, returning a new collection.
- *
+ *
* @param refs
* collection to be sorted
* @return sorted collection of refs
Collections.sort(r, INSTANCE);
return r;
}
-}
\ No newline at end of file
+}
/**
* Create a command to update, create or delete a ref in this repository.
- *
+ *
* @param name
* name of the ref the caller wants to modify.
* @return an update command. The caller must finish populating this command
/**
* Writes a symref (e.g. HEAD) to disk
- *
+ *
* @param name
* symref name
* @param target
return new Ref(Ref.Storage.LOOSE, origName, target, null);
if (!origName.equals(r.getName()))
r = new Ref(Ref.Storage.LOOSE_PACKED, origName, r.getName(), r.getObjectId(), r.getPeeledObjectId(), true);
- return r;
+ return r;
}
setModified();
/**
* Utility class to work with reflog files
- *
+ *
* @author Dave Watson
*/
public class RefLogWriter {
/**
* Writes reflog entry for ref specified by refName
- *
+ *
* @param repo
* repository to use
* @param oldCommit
String getToName() {
return newToUpdate.getName();
}
-}
\ No newline at end of file
+}
/**
* Get the name of the ref this update will operate on.
- *
+ *
* @return name of underlying ref.
*/
public String getName() {
/**
* Get the new value the ref will be (or was) updated to.
- *
+ *
* @return new value. Null if the caller has not configured it.
*/
public ObjectId getNewObjectId() {
/**
* Set the new value the ref will update to.
- *
+ *
* @param id
* the new value.
*/
/**
* Check if this update wants to forcefully change the ref.
- *
+ *
* @return true if this update should ignore merge tests.
*/
public boolean isForceUpdate() {
/**
* Set if this update wants to forcefully change the ref.
- *
+ *
* @param b
* true if this update should ignore merge tests.
*/
/**
* Get the message to include in the reflog.
- *
+ *
* @return message the caller wants to include in the reflog; null if the
* update should not be logged.
*/
/**
* Set the message to include in the reflog.
- *
+ *
* @param msg
* the message to describe this change. It may be null
* if appendStatus is null in order not to append to the reflog
* populated with the value of the ref before the lock is taken, but the old
* value may change if someone else modified the ref between the time we
* last read it and when the ref was locked for update.
- *
+ *
* @return the value of the ref prior to the update being attempted; null if
* the updated has not been attempted yet.
*/
* Get the status of this update.
* <p>
* The same value that was previously returned from an update method.
- *
+ *
* @return the status of the update.
*/
public Result getResult() {
* <p>
* This is just a convenient helper for setting the force flag, and as such
* the merge test is performed.
- *
+ *
* @return the result status of the update.
* @throws IOException
* an unexpected IO error occurred while writing changes.
* Merge test will be performed according to {@link #isForceUpdate()}.
* <p>
* This is the same as:
- *
+ *
* <pre>
* return update(new RevWalk(repository));
* </pre>
- *
+ *
* @return the result status of the update.
* @throws IOException
* an unexpected IO error occurred while writing changes.
* Gracefully update the ref to the new value.
* <p>
* Merge test will be performed according to {@link #isForceUpdate()}.
- *
+ *
* @param walk
* a RevWalk instance this update command can borrow to perform
* the merge test. The walk will be reset to perform the test.
* Delete the ref.
* <p>
* This is the same as:
- *
+ *
* <pre>
* return delete(new RevWalk(repository));
* </pre>
- *
+ *
* @return the result status of the delete.
* @throws IOException
*/
/**
* Delete the ref.
- *
+ *
* @param walk
* a RevWalk instance this delete command can borrow to perform
* the merge test. The walk will be reset to perform the test.
/**
* Writes out refs to the {@link Constants#INFO_REFS} and
* {@link Constants#PACKED_REFS} files.
- *
+ *
* This class is abstract as the writing of the files must be handled by the
* caller. This is because it is used by transport classes as well.
*/
* <p>
* This method rebuilds the contents of the {@link Constants#INFO_REFS} file
* to match the passed list of references.
- *
- *
+ *
+ *
* @throws IOException
* writing is not supported, or attempting to write the file
* failed, possibly due to permissions or remote disk full, etc.
* This method rebuilds the contents of the {@link Constants#PACKED_REFS}
* file to match the passed list of references, including only those refs
* that have a storage type of {@link Ref.Storage#PACKED}.
- *
+ *
* @throws IOException
* writing is not supported, or attempting to write the file
* failed, possibly due to permissions or remote disk full, etc.
/**
* Handles actual writing of ref files to the git repository, which may
* differ slightly depending on the destination and transport.
- *
+ *
* @param file
* path to ref file.
* @param content
/**
* Construct a representation of a Git repository.
- *
+ *
* @param d
* GIT_DIR (the location of the repository metadata).
* @throws IOException
/**
* @param id
* SHA-1 of an object.
- *
+ *
* @return a {@link ObjectLoader} for accessing the data of the named
* object, or null if the object does not exist.
* @throws IOException
* temporary working space associated with the calling thread.
* @param id
* SHA-1 of an object.
- *
+ *
* @return a {@link ObjectLoader} for accessing the data of the named
* object, or null if the object does not exist.
* @throws IOException
/**
* Create a command to update, create or delete a ref in this repository.
- *
+ *
* @param ref
* name of the ref the caller wants to modify.
* @return an update command. The caller must finish populating this command
refId = parents[0];
} else
throw new IncorrectObjectTypeException(refId, Constants.TYPE_COMMIT);
-
+
}
} else {
ref = mapObject(refId, null);
/**
* Add a single existing pack to the list of available pack files.
- *
+ *
* @param pack
* path of the pack file to open.
* @param idx
ref = ref.substring(5);
return ref;
}
-
+
/**
* @return name of current branch.
* @throws IOException
* <p>
* If the ref cannot be peeled (as it does not refer to an annotated tag)
* the peeled id stays null, but {@link Ref#isPeeled()} will be true.
- *
+ *
* @param ref
* The ref to peel
* @return <code>ref</code> if <code>ref.isPeeled()</code> is true; else a
return r.toString();
}
-}
\ No newline at end of file
+}
* The new configuration is applied immediately. If the new limits are
* smaller than what what is currently cached, older entries will be purged
* as soon as possible to allow the cache to meet the new limit.
- *
+ *
* @param packedGitLimit
* maximum number of bytes to hold within this instance.
* @param packedGitWindowSize
/**
* Copy bytes from the window to a caller supplied buffer.
- *
+ *
* @param pack
* the file the desired window is stored within.
* @param position
/**
* Pump bytes into the supplied inflater as input.
- *
+ *
* @param pack
* the file the desired window is stored within.
* @param position
File root;
GitIndex index;
-
+
private boolean failOnConflict = true;
Tree merge;
-
+
/**
- * If <code>true</code>, will scan first to see if it's possible to check out,
+ * If <code>true</code>, will scan first to see if it's possible to check out,
* otherwise throw {@link CheckoutConflictException}. If <code>false</code>,
* it will silently deal with the problem.
* @param failOnConflict
this.index = oldIndex;
this.merge = repo.mapTree(newIndex.writeTree());
}
-
+
/**
* Create a checkout class for checking out one tree, merging with the index
*
* @param index current index
* @param merge tree to check out
*/
- public WorkDirCheckout(Repository repo, File root,
+ public WorkDirCheckout(Repository repo, File root,
GitIndex index, Tree merge) {
this.repo = repo;
this.root = root;
this(repo, root, index, merge);
this.head = head;
}
-
+
/**
* Execute this checkout
*
throw new CheckoutConflictException(entries);
}
}
-
+
cleanUpConflicts();
if (head == null)
checkoutOutIndexNoHead();
for (String path : removed) {
index.remove(root, new File(root, path));
}
-
+
for (java.util.Map.Entry<String, ObjectId> entry : updated.entrySet()) {
Entry newEntry = index.addEntry(merge.findBlobMember(entry.getKey()));
index.checkoutEntry(root, newEntry);
Tree head = null;
HashMap<String, ObjectId> updated = new HashMap<String, ObjectId>();
-
+
private void checkoutOutIndexNoHead() throws IOException {
new IndexTreeWalker(index, merge, root, new AbstractIndexTreeVisitor() {
public void visitEntry(TreeEntry m, Entry i, File f) throws IOException {
if (i.isModified(root, true))
needsCheckout = true;
} else needsCheckout = true;
-
+
if (needsCheckout) {
Entry newEntry = index.addEntry(m);
index.checkoutEntry(root, newEntry);
if (parentFile.list().length == 0)
parentFile.delete();
else break;
-
+
parentFile = parentFile.getParentFile();
- }
+ }
}
void prescanOneTree() throws IOException {
}).walk();
conflicts.removeAll(removed);
}
-
+
private ArrayList<String> listFiles(File file) {
ArrayList<String> list = new ArrayList<String>();
listFiles(file, list);
return list;
- }
+ }
private void listFiles(File dir, ArrayList<String> list) {
for (File f : dir.listFiles()) {
}
processEntry(treeEntry, auxEntry, indexEntry);
}
-
+
@Override
public void finishVisitTree(Tree tree, Tree auxTree, String curDir) throws IOException {
if (curDir.length() == 0) return;
-
+
if (auxTree != null) {
if (index.getEntry(curDir) != null)
removed.add(curDir);
- }
+ }
}
-
+
}).walk();
-
+
// if there's a conflict, don't list it under
// to-be-removed, since that messed up our next
// section
removed.removeAll(conflicts);
-
+
for (String path : updated.keySet()) {
if (index.getEntry(path) == null) {
File file = new File(root, path);
}
}
}
-
-
+
+
conflicts.removeAll(removed);
}
ObjectId iId = (i == null ? null : i.getObjectId());
ObjectId mId = (m == null ? null : m.getId());
ObjectId hId = (h == null ? null : h.getId());
-
- String name = (i != null ? i.getName() :
+
+ String name = (i != null ? i.getName() :
(h != null ? h.getFullName() :
m.getFullName()));
-
+
if (i == null) {
/*
I (index) H M Result
1 nothing nothing exists use M
2 nothing exists nothing remove path from index
3 nothing exists exists use M */
-
+
if (h == null) {
updated.put(name,mId);
} else if (m == null) {
-----------------------------------------------------
4 yes N/A N/A nothing nothing keep index
5 no N/A N/A nothing nothing keep index
-
+
6 yes N/A yes nothing exists keep index
7 no N/A yes nothing exists keep index
8 yes N/A no nothing exists fail
9 no N/A no nothing exists fail */
-
+
if (m == null || mId.equals(iId)) {
if (hasParentBlob(merge, name)) {
if (i.isModified(root, true)) {
12 yes no N/A exists nothing fail
13 no no N/A exists nothing fail
*/
-
+
if (hId.equals(iId)) {
if (i.isModified(root, true)) {
conflicts.add(name);
conflicts.add(name);
else updated.put(name, mId);
}
- }
+ }
}
private boolean hasParentBlob(Tree t, String name) throws IOException {
if (name.indexOf("/") == -1) return false;
-
+
String parent = name.substring(0, name.lastIndexOf("/"));
- if (t.findBlobMember(parent) != null)
+ if (t.findBlobMember(parent) != null)
return true;
return hasParentBlob(t, parent);
}
* starts at (upper left corner is) 0,0. If this is not true (like say in SWT)
* the implementation must perform the cell offset computations within the
* various draw methods.
- *
+ *
* @param <TLane>
* type of lane being used by the application.
* @param <TColor>
/**
* Paint one commit using the underlying graphics library.
- *
+ *
* @param commit
* the commit to render in this cell. Must not be null.
* @param h
* If a null lane is supplied the return value must still be acceptable to a
* drawing method. Usually this means the implementation should return a
* default color.
- *
+ *
* @param myLane
* the current lane. May be null.
* @return graphics specific color reference. Must be a valid color.
/**
* Draw a single line within this cell.
- *
+ *
* @param color
* the color to use while drawing the line.
* @param x1
* <p>
* Usually the commit dot is a filled oval in blue, then a drawn oval in
* black, using the same coordinates for both operations.
- *
+ *
* @param x
* upper left of the oval's bounding box.
* @param y
* Draw a single boundary commit (aka uninteresting commit) dot.
* <p>
* Usually a boundary commit dot is a light gray oval with a white center.
- *
+ *
* @param x
* upper left of the oval's bounding box.
* @param y
* <p>
* The font and colors used to render the text are left up to the
* implementation.
- *
+ *
* @param msg
* the text to draw. Does not contain LFs.
* @param x
/**
* A commit reference to a commit in the DAG.
- *
+ *
* @param <L>
* type of lane being used by the plotter.
* @see PlotCommitList
/**
* Create a new commit.
- *
+ *
* @param id
* the identity of this commit.
* @param tags
/**
* Get the number of child commits listed in this commit.
- *
+ *
* @return number of children; always a positive value but can be 0.
*/
public final int getChildCount() {
/**
* Get the nth child from this commit's child list.
- *
+ *
* @param nth
* child index to obtain. Must be in the range 0 through
* {@link #getChildCount()}-1.
/**
* Determine if the given commit is a child (descendant) of this commit.
- *
+ *
* @param c
* the commit to test.
* @return true if the given commit built on top of this commit.
/**
* Obtain the lane this commit has been plotted into.
- *
+ *
* @return the assigned lane for this commit.
*/
public final L getLane() {
* <p>
* The source of the list must be a {@link PlotWalk} and {@link #fillTo(int)}
* must be used to populate the list.
- *
+ *
* @param <L>
* type of lane used by the application.
*/
* <p>
* This method modifies the passed collection by adding the lanes in any
* order.
- *
+ *
* @param currCommit
* the commit the caller needs to get the lanes from.
* @param result
/**
* Return colors and other reusable information to the plotter when a lane
* is no longer needed.
- *
+ *
* @param lane
*/
protected void recycleLane(final L lane) {
/**
* Logical location of this lane within the graphing plane.
- *
+ *
* @return location of this lane, 0 through the maximum number of lanes.
*/
public int getPosition() {
/**
* Create a new revision walker for a given repository.
- *
+ *
* @param repo
* the repository the walker will obtain data from.
*/
* This method always adds the commit, even if it is already in the queue or
* previously was in the queue but has already been removed. To control
* queue admission use {@link #add(RevCommit, RevFlag)}.
- *
+ *
* @param c
* commit to add.
*/
* flag; if it does not already have the flag than the commit is added to
* the queue and the flag is set. This later will prevent the commit from
* being added twice.
- *
+ *
* @param c
* commit to add.
* @param queueControl
* flag; if it does not already have the flag than the commit is added to
* the queue and the flag is set. This later will prevent the commit from
* being added twice.
- *
+ *
* @param c
* commit whose parents should be added.
* @param queueControl
/**
* Remove the first commit from the queue.
- *
+ *
* @return the first commit of this queue.
*/
public abstract RevCommit next();
* <p>
* Free lists are not thread-safe. Applications must ensure that all queues
* sharing the same free list are doing so from only a single thread.
- *
+ *
* @param q
* the other queue we will steal entries from.
*/
/**
* Peek at the next commit, without removing it.
- *
+ *
* @return the next available commit; null if there are no commits left.
*/
public RevCommit peek() {
/**
* Insert the commit pointer at the front of the queue.
- *
+ *
* @param c
* the commit to insert into the queue.
*/
* Conceptually a Generator is an iterator or a queue, it returns commits until
* there are no more relevant. Generators may be piped/stacked together to
* create a more complex set of operations.
- *
+ *
* @see PendingGenerator
* @see StartGenerator
*/
/**
* Connect the supplied queue to this generator's own free list (if any).
- *
+ *
* @param q
* another FIFO queue that wants to share our queue's free list.
*/
/**
* Obtain flags describing the output behavior of this generator.
- *
+ *
* @return one or more of the constants declared in this class, describing
* how this generator produces its results.
*/
/**
* Return the next commit to the application, or the next generator.
- *
+ *
* @return next available commit; null if no more are to be returned.
* @throws MissingObjectException
* @throws IncorrectObjectTypeException
/**
* Create a new revision and object walker for a given repository.
- *
+ *
* @param repo
* the repository the walker will obtain data from.
*/
* This method will automatically call {@link RevWalk#markStart(RevCommit)}
* if passed RevCommit instance, or a RevTag that directly (or indirectly)
* references a RevCommit.
- *
+ *
* @param o
* the object to start traversing from. The object passed must be
* from this same revision walker.
* This method will automatically call {@link RevWalk#markStart(RevCommit)}
* if passed RevCommit instance, or a RevTag that directly (or indirectly)
* references a RevCommit.
- *
+ *
* @param o
* the object to start traversing from. The object passed must be
* @throws MissingObjectException
/**
* Pop the next most recent object.
- *
+ *
* @return next most recent object; null if traversal is over.
* @throws MissingObjectException
* one or or more of the next objects are not available from the
* This method returns successfully if everything is connected; it throws an
* exception if there is a connectivity problem. The exception message
* provides some detail about the connectivity failure.
- *
+ *
* @throws MissingObjectException
* one or or more of the next objects are not available from the
* object database, but were thought to be candidates for
* and final output generation. Applications should try to avoid calling it,
* and if invoked do so only once per interesting entry, where the name is
* absolutely required for correct function.
- *
+ *
* @return complete path of the current entry, from the root of the
* repository. If the current entry is in a subtree there will be at
* least one '/' in the returned string. Null if the current entry
public class RevBlob extends RevObject {
/**
* Create a new blob reference.
- *
+ *
* @param id
* object name for the blob.
*/
/**
* Create a new commit reference.
- *
+ *
* @param id
* object name for the commit.
*/
buffer = raw;
flags |= PARSED;
}
-
+
@Override
public final int getType() {
return Constants.OBJ_COMMIT;
* an unparsed commit or a commit with no parents is discovered. This
* permits applications to force a flag through the history chain when
* necessary.
- *
+ *
* @param flag
* the single flag value to carry back onto parents.
*/
/**
* Time from the "committer " line of the buffer.
- *
+ *
* @return time, expressed as seconds since the epoch.
*/
public final int getCommitTime() {
/**
* Parse this commit buffer for display.
- *
+ *
* @param walk
* revision walker owning this reference.
* @return parsed commit.
/**
* Get a reference to this commit's tree.
- *
+ *
* @return tree of this commit.
*/
public final RevTree getTree() {
/**
* Get the number of parent commits listed in this commit.
- *
+ *
* @return number of parents; always a positive value but can be 0.
*/
public final int getParentCount() {
/**
* Get the nth parent from this commit's parent list.
- *
+ *
* @param nth
* parent index to obtain. Must be in the range 0 through
* {@link #getParentCount()}-1.
* this commit's parent list. Applications relying on this list should be
* very careful to ensure they do not modify its contents during their use
* of it.
- *
+ *
* @return the array of parents.
*/
public final RevCommit[] getParents() {
* this commit's message buffer within a RevFilter. Applications relying on
* this buffer should be very careful to ensure they do not modify its
* contents during their use of it.
- *
+ *
* @return the raw unparsed commit body. This is <b>NOT A COPY</b>.
* Altering the contents of this buffer may alter the walker's
* knowledge of this commit, and the results it produces.
* RevFilter implementations should try to use {@link RawParseUtils} to scan
* the {@link #getRawBuffer()} instead, as this will allow faster evaluation
* of commits.
- *
+ *
* @return identity of the author (name, email) and the time the commit was
* made by the author; null if no author line was found.
*/
* RevFilter implementations should try to use {@link RawParseUtils} to scan
* the {@link #getRawBuffer()} instead, as this will allow faster evaluation
* of commits.
- *
+ *
* @return identity of the committer (name, email) and the time the commit
* was made by the committer; null if no committer line was found.
*/
* after taking the commit's character set into account and decoding the
* buffer using that character set. This method is a fairly expensive
* operation and produces a new string on each invocation.
- *
+ *
* @return decoded commit message as a string. Never null.
*/
public final String getFullMessage() {
* after taking the commit's character set into account and decoding the
* buffer using that character set. This method is a fairly expensive
* operation and produces a new string on each invocation.
- *
+ *
* @return decoded commit message as a string. Never null. The returned
* string does not contain any LFs, even if the first paragraph
* spanned multiple lines. Embedded LFs are converted to spaces.
/**
* An ordered list of {@link RevCommit} subclasses.
- *
+ *
* @param <E>
* type of subclass of RevCommit the list is storing.
*/
* <p>
* Same as <code>applyFlag(matching, flag, 0, size())</code>, but without
* the incremental behavior.
- *
+ *
* @param matching
* the filter to test commits with. If the filter includes a
* commit it will have the flag set; if the filter does not
* This version allows incremental testing and application, such as from a
* background thread that needs to periodically halt processing and send
* updates to the UI.
- *
+ *
* @param matching
* the filter to test commits with. If the filter includes a
* commit it will have the flag set; if the filter does not
* <p>
* Same as <code>clearFlag(flag, 0, size())</code>, but without the
* incremental behavior.
- *
+ *
* @param flag
* the flag to remove. Applications are responsible for
* allocating this flag from the source RevWalk.
* <p>
* This method is actually implemented in terms of:
* <code>applyFlag(RevFilter.NONE, flag, rangeBegin, rangeEnd)</code>.
- *
+ *
* @param flag
* the flag to remove. Applications are responsible for
* allocating this flag from the source RevWalk.
/**
* Find the next commit that has the given flag set.
- *
+ *
* @param flag
* the flag to test commits against.
* @param begin
/**
* Find the next commit that has the given flag set.
- *
+ *
* @param flag
* the flag to test commits against.
* @param begin
/**
* Set the revision walker this list populates itself from.
- *
+ *
* @param w
* the walker to populate from.
* @see #fillTo(int)
/**
* Is this list still pending more items?
- *
+ *
* @return true if {@link #fillTo(int)} might be able to extend the list
* size when called.
*/
* fewer total commits available from the walk then the method will return
* early. Callers can test the final size of the list by {@link #size()} to
* determine if the high water mark specified was met.
- *
+ *
* @param highMark
* number of commits the caller wants this list to contain when
* the fill operation is complete.
* Optional callback invoked when commits enter the list by fillTo.
* <p>
* This method is only called during {@link #fillTo(int)}.
- *
+ *
* @param index
* the list position this object will appear at.
* @param e
/**
* Get the revision walk instance this flag was created from.
- *
+ *
* @return the walker this flag was allocated out of, and belongs to.
*/
public RevWalk getRevWalk() {
/**
* Multiple application level mark bits for {@link RevObject}s.
- *
+ *
* @see RevFlag
*/
public class RevFlagSet extends AbstractSet<RevFlag> {
/**
* Create a set of flags, copied from an existing set.
- *
+ *
* @param s
* the set to copy flags from.
*/
/**
* Create a set of flags, copied from an existing collection.
- *
+ *
* @param s
* the collection to copy flags from.
*/
/**
* Get Git object type. See {@link Constants}.
- *
+ *
* @return object type
*/
public abstract int getType();
/**
* Get the name of this object.
- *
+ *
* @return unique hash of this object.
*/
public final ObjectId getId() {
/**
* Test to see if the flag has been set on this object.
- *
+ *
* @param flag
* the flag to test.
* @return true if the flag has been added to this object; false if not.
/**
* Test to see if any flag in the set has been set on this object.
- *
+ *
* @param set
* the flags to test.
* @return true if any flag in the set has been added to this object; false
/**
* Test to see if all flags in the set have been set on this object.
- *
+ *
* @param set
* the flags to test.
* @return true if all flags of the set have been added to this object;
* Add a flag to this object.
* <p>
* If the flag is already set on this object then the method has no effect.
- *
+ *
* @param flag
* the flag to mark on this object, for later testing.
*/
/**
* Add a set of flags to this object.
- *
+ *
* @param set
* the set of flags to mark on this object, for later testing.
*/
* Remove a flag from this object.
* <p>
* If the flag is not set on this object then the method has no effect.
- *
+ *
* @param flag
* the flag to remove from this object.
*/
/**
* Remove a set of flags from this object.
- *
+ *
* @param set
* the flag to remove from this object.
*/
/**
* An ordered list of {@link RevObject} subclasses.
- *
+ *
* @param <E>
* type of subclass of RevObject the list is storing.
*/
/**
* Create a new tag reference.
- *
+ *
* @param id
* object name for the tag.
*/
/**
* Parse this tag buffer for display.
- *
+ *
* @param walk
* revision walker owning this reference.
* @return parsed tag.
/**
* Get a reference to the object this tag was placed on.
- *
+ *
* @return object this tag refers to.
*/
public final RevObject getObject() {
/**
* Get the name of this tag, from the tag header.
- *
+ *
* @return name of the tag, according to the tag header.
*/
public final String getTagName() {
public class RevTree extends RevObject {
/**
* Create a new tree reference.
- *
+ *
* @param id
* object name for the tree.
*/
* mark the commit REWRITE. Later we can rewrite the parents of a REWRITE
* child to remove chains of REWRITE commits before we produce the child to
* the application.
- *
+ *
* @see RewriteGenerator
*/
static final int REWRITE = 1 << 3;
/**
* Create a new revision walker for a given repository.
- *
+ *
* @param repo
* the repository the walker will obtain data from.
*/
/**
* Get the repository this walker loads objects from.
- *
+ *
* @return the repository this walker was created to read.
*/
public Repository getRepository() {
* handling may be more difficult for the application to explain why a
* RevCommit is not actually a commit. The object pool of this walker would
* also be 'poisoned' by the non-commit RevCommit.
- *
+ *
* @param c
* the commit to start traversing from. The commit passed must be
* from this same revision walker.
/**
* Mark commits to start graph traversal from.
- *
+ *
* @param list
* commits to start traversing from. The commits passed must be
* from this same revision walker.
* handling may be more difficult for the application to explain why a
* RevCommit is not actually a commit. The object pool of this walker would
* also be 'poisoned' by the non-commit RevCommit.
- *
+ *
* @param c
* the commit to start traversing from. The commit passed must be
* from this same revision walker.
* commits, and then executes a walk until an answer can be obtained.
* Currently allocated RevFlags that have been added to RevCommit instances
* will be retained through the reset.
- *
+ *
* @param base
* commit the caller thinks is reachable from <code>tip</code>.
* @param tip
/**
* Pop the next most recent commit.
- *
+ *
* @return next most recent commit; null if traversal is over.
* @throws MissingObjectException
* one or or more of the next commit's parents are not available
/**
* Obtain the sort types applied to the commits returned.
- *
+ *
* @return the sorting strategies employed. At least one strategy is always
* used, but that strategy may be {@link RevSort#NONE}.
*/
* <p>
* Disables all sorting strategies, then enables only the single strategy
* supplied by the caller.
- *
+ *
* @param s
* a sorting strategy to enable.
*/
* may take precedence over others. As an example, {@link RevSort#TOPO} must
* take precedence over {@link RevSort#COMMIT_TIME_DESC}, otherwise it
* cannot enforce its ordering.
- *
+ *
* @param s
* a sorting strategy to enable or disable.
* @param use
/**
* Get the currently configured commit filter.
- *
+ *
* @return the current filter. Never null as a filter is always needed.
*/
public RevFilter getRevFilter() {
* unless the filter implementation specifically states it is (and always
* will be) thread-safe. Callers may use {@link RevFilter#clone()} to create
* a unique filter tree for this RevWalk instance.
- *
+ *
* @param newFilter
* the new filter. If null the special {@link RevFilter#ALL}
* filter will be used instead, as it matches every commit.
/**
* Get the tree filter used to simplify commits by modified paths.
- *
+ *
* @return the current filter. Never null as a filter is always needed. If
* no filter is being applied {@link TreeFilter#ALL} is returned.
*/
* Usually callers should be inserting a filter graph including
* {@link TreeFilter#ANY_DIFF} along with one or more
* {@link org.eclipse.jgit.treewalk.filter.PathFilter} instances.
- *
+ *
* @param newFilter
* new filter. If null the special {@link TreeFilter#ALL} filter
* will be used instead, as it matches everything.
* <p>
* The tree may or may not exist in the repository. It is impossible to tell
* from this method's return value.
- *
+ *
* @param id
* name of the tree object.
* @return reference to the tree object. Never null.
* <p>
* The commit may or may not exist in the repository. It is impossible to
* tell from this method's return value.
- *
+ *
* @param id
* name of the commit object.
* @return reference to the commit object. Never null.
* <p>
* The object may or may not exist in the repository. It is impossible to
* tell from this method's return value.
- *
+ *
* @param id
* name of the object.
* @param type
* Unlike {@link #lookupCommit(AnyObjectId)} this method only returns
* successfully if the commit object exists, is verified to be a commit, and
* was parsed without error.
- *
+ *
* @param id
* name of the commit object.
* @return reference to the commit object. Never null.
* without error. Parsing an object can be expensive as the type must be
* determined. For blobs this may mean the blob content was unpacked
* unnecessarily, and thrown away.
- *
+ *
* @param id
* name of the object.
* @return reference to the object. Never null.
* <p>
* This method only returns successfully if the object exists and was parsed
* without error.
- *
+ *
* @param obj
* the object the caller needs to be parsed.
* @throws MissingObjectException
* Applications are only assured to be able to create 24 unique flags on any
* given revision walker instance. Any flags beyond 24 are offered only if
* the implementation has extra free space within its internal storage.
- *
+ *
* @param name
* description of the flag, primarily useful for debugging.
* @return newly constructed flag instance.
* <p>
* A carried flag is copied from the child commit onto its parents when the
* child commit is popped from the lowest level of walk's internal graph.
- *
+ *
* @param flag
* the flag to carry onto parents, if set on a descendant.
*/
* <p>
* A carried flag is copied from the child commit onto its parents when the
* child commit is popped from the lowest level of walk's internal graph.
- *
+ *
* @param set
* the flags to carry onto parents, if set on a descendant.
*/
* If the flag was previously being carried, the carrying request is
* removed. Disposing of a carried flag while a traversal is in progress has
* an undefined behavior.
- *
+ *
* @param flag
* the to recycle.
*/
* Unlike {@link #dispose()} previously acquired RevObject (and RevCommit)
* instances are not invalidated. RevFlag instances are not invalidated, but
* are removed from all RevObjects.
- *
+ *
* @param retainFlags
* application flags that should <b>not</b> be cleared from
* existing commit objects.
* Unlike {@link #dispose()} previously acquired RevObject (and RevCommit)
* instances are not invalidated. RevFlag instances are not invalidated, but
* are removed from all RevObjects.
- *
+ *
* @param retainFlags
* application flags that should <b>not</b> be cleared from
* existing commit objects.
* Unlike {@link #dispose()} previously acquired RevObject (and RevCommit)
* instances are not invalidated. RevFlag instances are not invalidated, but
* are removed from all RevObjects.
- *
+ *
* @param retainFlags
* application flags that should <b>not</b> be cleared from
* existing commit objects.
* <p>
* If a checked exception is thrown during the walk (see {@link #next()})
* it is rethrown from the Iterator as a {@link RevWalkException}.
- *
+ *
* @return an iterator over this walker's commits.
* @see RevWalkException
*/
/**
* Construct a new unparsed commit for the given object.
- *
+ *
* @param id
* the object this walker requires a commit reference for.
* @return a new unparsed reference for the object.
* that makes the DAG dense. Not fully buffering the commits first would cause
* this loop to abort early, due to commits not being parsed and colored
* correctly.
- *
+ *
* @see RewriteTreeFilter
*/
class RewriteGenerator extends Generator {
* the commit is colored with {@link RevWalk#REWRITE}, allowing a later pass
* implemented by {@link RewriteGenerator} to remove those colored commits from
* the DAG.
- *
+ *
* @see RewriteGenerator
*/
class RewriteTreeFilter extends RevFilter {
* When the constructor completes the supplied generator will have no
* commits remaining, as all of the commits will be held inside of this
* generator's internal buffer.
- *
+ *
* @param s
* generator to pull all commits out of, and into this buffer.
* @throws MissingObjectException
public abstract class CommitTimeRevFilter extends RevFilter {
/**
* Create a new filter to select commits before a given date/time.
- *
+ *
* @param ts
* the point in time to cut on.
* @return a new filter to select commits on or before <code>ts</code>.
/**
* Create a new filter to select commits after a given date/time.
- *
+ *
* @param ts
* the point in time to cut on.
* @return a new filter to select commits on or after <code>ts</code>.
public abstract class OrRevFilter extends RevFilter {
/**
* Create a filter with two filters, one of which must match.
- *
+ *
* @param a
* first filter to test.
* @param b
/**
* Create a filter around many filters, one of which must match.
- *
+ *
* @param list
* list of filters to match against. Must contain at least 2
* filters.
/**
* Create a filter around many filters, one of which must match.
- *
+ *
* @param list
* list of filters to match against. Must contain at least 2
* filters.
public abstract class RevFlagFilter extends RevFilter {
/**
* Create a new filter that tests for a single flag.
- *
+ *
* @param a
* the flag to test.
* @return filter that selects only commits with flag <code>a</code>.
/**
* Create a new filter that tests all flags in a set.
- *
+ *
* @param a
* set of flags to test.
* @return filter that selects only commits with all flags in <code>a</code>.
/**
* Create a new filter that tests all flags in a set.
- *
+ *
* @param a
* set of flags to test.
* @return filter that selects only commits with all flags in <code>a</code>.
/**
* Create a new filter that tests for any flag in a set.
- *
+ *
* @param a
* set of flags to test.
* @return filter that selects only commits with any flag in <code>a</code>.
/**
* Create a new filter that tests for any flag in a set.
- *
+ *
* @param a
* set of flags to test.
* @return filter that selects only commits with any flag in <code>a</code>.
public abstract class SubStringRevFilter extends RevFilter {
/**
* Can this string be safely handled by a substring filter?
- *
+ *
* @param pattern
* the pattern text proposed by the user.
* @return true if a substring filter can perform this pattern match; false
/**
* Construct a new matching filter.
- *
+ *
* @param patternText
* text to locate. This should be a safe string as described by
* the {@link #safe(String)} as regular expression meta
/**
* Obtain the raw text to match against.
- *
+ *
* @param cmit
* current commit being evaluated.
* @return sequence for the commit's content that we need to match on.
private static class CancelledException extends Exception {
private static final long serialVersionUID = 1L;
}
-}
\ No newline at end of file
+}
*/
public void close();
-}
\ No newline at end of file
+}
* <p>
* FetchConnection instances are not thread safe and may be accessed by only one
* thread at a time.
- *
+ *
* @see Transport
*/
public interface FetchConnection extends Connection {
* should always be preferred over remotely available objects and packs.
* {@link Transport#isFetchThin()} should be honored if applicable.
* </p>
- *
+ *
* @param monitor
* progress monitor to inform the end-user about the amount of
* work completed, or to indicate cancellation. Implementations
* By returning only true/false (and not the actual list of tags obtained)
* the transport itself does not need to be aware of whether or not tags
* were included in the transfer.
- *
+ *
* @return true if the last fetch call implicitly included tag objects;
* false if tags were not implicitly obtained.
*/
/**
* Final status after a successful fetch from a remote repository.
- *
+ *
* @see Transport#fetch(org.eclipse.jgit.lib.ProgressMonitor, Collection)
*/
public class FetchResult extends OperationResult {
* files within the repository's <code>objects</code> directory. To use the
* data contained within them call {@link #renameAndOpenPack()} once the
* indexing is complete.
- *
+ *
* @param db
* the repository that will receive the new pack.
* @param is
/**
* Create a new pack indexer utility.
- *
+ *
* @param db
* @param src
* stream to read the pack data from. If the stream is buffered
* Thin packs are sometimes used during network transfers to allow a delta
* to be sent without a base object. Such packs are not permitted on disk.
* They can be fixed by copying the base object onto the end of the pack.
- *
+ *
* @param fix
* true to enable fixing a thin pack.
*/
/**
* Consume data from the input stream until the packfile is indexed.
- *
+ *
* @param progress
* progress feedback
- *
+ *
* @throws IOException
*/
public void index(final ProgressMonitor progress) throws IOException {
* If the call completes successfully the repository this IndexPack instance
* was created with will have the objects in the pack available for reading
* and use, without needing to scan for packs.
- *
+ *
* @throws IOException
* The pack could not be inserted into the repository's objects
* directory. The pack no longer exists on disk, as it was
void add(final TrackingRefUpdate u) {
updates.put(u.getLocalName(), u);
}
-}
\ No newline at end of file
+}
* Implementations of PackTransport setup connections and move objects back and
* forth by creating pack files on the source side and indexing them on the
* receiving side.
- *
+ *
* @see BasePackFetchConnection
* @see BasePackPushConnection
*/
* <p>
* PushConnection instances are not thread safe and may be accessed by only one
* thread at a time.
- *
+ *
* @see Transport
*/
public interface PushConnection extends Connection {
* <li><code>+refs/head/*:refs/remotes/origin/*</code></li>
* <li><code>:refs/head/master</code></li>
* </ul>
- *
+ *
* @param spec
* string describing the specification.
* @throws IllegalArgumentException
/**
* Check if this specification wants to forcefully update the destination.
- *
+ *
* @return true if this specification asks for updates without merge tests.
*/
public boolean isForceUpdate() {
/**
* Create a new RefSpec with a different force update setting.
- *
+ *
* @param forceUpdate
* new value for force update in the returned instance.
* @return a new RefSpec with force update as specified.
* If this is a wildcard pattern then the source and destination names
* returned by {@link #getSource()} and {@link #getDestination()} will not
* be actual ref names, but instead will be patterns.
- *
+ *
* @return true if this specification could match more than one ref.
*/
public boolean isWildcard() {
* During a fetch this is the name of the ref on the remote repository we
* are fetching from. During a push this is the name of the ref on the local
* repository we are pushing out from.
- *
+ *
* @return name (or wildcard pattern) to match the source ref.
*/
public String getSource() {
/**
* Create a new RefSpec with a different source name setting.
- *
+ *
* @param source
* new value for source in the returned instance.
* @return a new RefSpec with source as specified.
* ObjectId should be stored transiently in order to prepare a merge.
* <p>
* If null during a push, use {@link #getSource()} instead.
- *
+ *
* @return name (or wildcard) pattern to match the destination ref.
*/
public String getDestination() {
/**
* Create a new RefSpec with a different destination name setting.
- *
+ *
* @param destination
* new value for destination in the returned instance.
* @return a new RefSpec with destination as specified.
/**
* Create a new RefSpec with a different source/destination name setting.
- *
+ *
* @param source
* new value for source in the returned instance.
* @param destination
/**
* Does this specification's source description match the ref?
- *
+ *
* @param r
* ref whose name should be tested.
* @return true if the names match; false otherwise.
/**
* Does this specification's destination description match the ref?
- *
+ *
* @param r
* ref whose name should be tested.
* @return true if the names match; false otherwise.
* <p>
* Callers must first verify the passed ref matches this specification,
* otherwise expansion results may be unpredictable.
- *
+ *
* @param r
* a ref that matched our source specification. Could be a
* wildcard also.
* This constructor succeeds even if the requested remote is not defined
* within the supplied configuration file. If that occurs then there will be
* no URIs and no ref specifications known to the new instance.
- *
+ *
* @param rc
* the existing configuration to get the remote settings from.
* The configuration must already be loaded into memory.
/**
* Update this remote's definition within the configuration.
- *
+ *
* @param rc
* the configuration file to store ourselves into.
*/
/**
* Get the local name this remote configuration is recognized as.
- *
+ *
* @return name assigned by the user to this configuration block.
*/
public String getName() {
/**
* Get all configured URIs under this remote.
- *
+ *
* @return the set of URIs known to this remote.
*/
public List<URIish> getURIs() {
/**
* Add a new URI to the end of the list of URIs.
- *
+ *
* @param toAdd
* the new URI to add to this remote.
* @return true if the URI was added; false if it already exists.
/**
* Remove a URI from the list of URIs.
- *
+ *
* @param toRemove
* the URI to remove from this remote.
* @return true if the URI was added; false if it already exists.
/**
* Remembered specifications for fetching from a repository.
- *
+ *
* @return set of specs used by default when fetching.
*/
public List<RefSpec> getFetchRefSpecs() {
/**
* Add a new fetch RefSpec to this remote.
- *
+ *
* @param s
* the new specification to add.
* @return true if the specification was added; false if it already exists.
/**
* Remove a fetch RefSpec from this remote.
- *
+ *
* @param s
* the specification to remove.
* @return true if the specification existed and was removed.
/**
* Remembered specifications for pushing to a repository.
- *
+ *
* @return set of specs used by default when pushing.
*/
public List<RefSpec> getPushRefSpecs() {
/**
* Add a new push RefSpec to this remote.
- *
+ *
* @param s
* the new specification to add.
* @return true if the specification was added; false if it already exists.
/**
* Remove a push RefSpec from this remote.
- *
+ *
* @param s
* the specification to remove.
* @return true if the specification existed and was removed.
* This value is only useful for an SSH style connection, where Git is
* asking the remote system to execute a program that provides the necessary
* network protocol.
- *
+ *
* @return location of 'git-upload-pack' on the remote system. If no
* location has been configured the default of 'git-upload-pack' is
* returned instead.
* This value is only useful for an SSH style connection, where Git is
* asking the remote system to execute a program that provides the necessary
* network protocol.
- *
+ *
* @return location of 'git-receive-pack' on the remote system. If no
* location has been configured the default of 'git-receive-pack' is
* returned instead.
/**
* Get the description of how annotated tags should be treated during fetch.
- *
+ *
* @return option indicating the behavior of annotated tags in fetch.
*/
public TagOpt getTagOpt() {
/**
* Set the description of how annotated tags should be treated on fetch.
- *
+ *
* @param option
* method to use when handling annotated tags.
*/
* <p>
* Channel 3 results in an exception being thrown, as the remote side has issued
* an unrecoverable error.
- *
+ *
* @see PacketLineIn#sideband(ProgressMonitor)
*/
class SideBandInputStream extends InputStream {
* <p>
* A factory is always available. By default the factory will read from the
* user's <code>$HOME/.ssh</code> and assume OpenSSH compatibility.
- *
+ *
* @return factory the current factory for this JVM.
*/
public static SshSessionFactory getInstance() {
/**
* Change the JVM-wide factory to a different implementation.
- *
+ *
* @param newFactory
* factory for future sessions to be created through. If null the
* default factory will be restored.s
* <p>
* The caller must connect the session by invoking <code>connect()</code>
* if it has not already been connected.
- *
+ *
* @param user
* username to authenticate as. If null a reasonable default must
* be selected by the implementation. This may be
/**
* Close (or recycle) a session to a host.
- *
+ *
* @param session
* a session previously obtained from this factory's
* {@link #getSession(String,String, String, int)} method.s
/**
* Get the command line/configuration file text for this value.
- *
+ *
* @return text that appears in the configuration file to activate this.
*/
public String option() {
/**
* Convert a command line/configuration file text into a value instance.
- *
+ *
* @param o
* the configuration file text value.
* @return the option that matches the passed parameter.
* Get the name of the remote ref.
* <p>
* Usually this is of the form "refs/heads/master".
- *
+ *
* @return the name used within the remote repository.
*/
public String getRemoteName() {
* Get the name of the local tracking ref.
* <p>
* Usually this is of the form "refs/remotes/origin/master".
- *
+ *
* @return the name used within this local repository.
*/
public String getLocalName() {
/**
* Get the new value the ref will be (or was) updated to.
- *
+ *
* @return new value. Null if the caller has not configured it.
*/
public ObjectId getNewObjectId() {
* populated with the value of the ref before the lock is taken, but the old
* value may change if someone else modified the ref between the time we
* last read it and when the ref was locked for update.
- *
+ *
* @return the value of the ref prior to the update being attempted; null if
* the updated has not been attempted yet.
*/
/**
* Get the status of this update.
- *
+ *
* @return the status of the update.
*/
public Result getResult() {
* Open a new transport instance to connect two repositories.
* <p>
* This method assumes {@link Operation#FETCH}.
- *
+ *
* @param local
* existing local repository.
* @param remote
* Open a new transport instance to connect two repositories.
* <p>
* This method assumes {@link Operation#FETCH}.
- *
+ *
* @param local
* existing local repository.
* @param cfg
/**
* Open a new transport instance to connect two repositories.
- *
+ *
* @param local
* existing local repository.
* @param remote
/**
* Create a new transport instance.
- *
+ *
* @param local
* the repository this instance will fetch into, or push out of.
* This must be the repository passed to
* Get the URI this transport connects to.
* <p>
* Each transport instance connects to at most one URI at any point in time.
- *
+ *
* @return the URI describing the location of the remote repository.
*/
public URIish getURI() {
/**
* Get the name of the remote executable providing upload-pack service.
- *
+ *
* @return typically "git-upload-pack".
*/
public String getOptionUploadPack() {
/**
* Set the name of the remote executable providing upload-pack services.
- *
+ *
* @param where
* name of the executable.
*/
/**
* Get the description of how annotated tags should be treated during fetch.
- *
+ *
* @return option indicating the behavior of annotated tags in fetch.
*/
public TagOpt getTagOpt() {
/**
* Set the description of how annotated tags should be treated on fetch.
- *
+ *
* @param option
* method to use when handling annotated tags.
*/
* tracking refs associated with the remote repository are automatically
* updated if this transport was created from a {@link RemoteConfig} with
* fetch RefSpecs defined.
- *
+ *
* @param monitor
* progress monitor to inform the user about our processing
* activity. Must not be null. Use {@link NullProgressMonitor} if
/**
* Begins a new connection for fetching from the remote repository.
- *
+ *
* @return a fresh connection to fetch from the remote repository.
* @throws NotSupportedException
* the implementation does not support fetching.
/**
* Begins a new connection for pushing into the remote repository.
- *
+ *
* @return a fresh connection to push into the remote repository.
* @throws NotSupportedException
* the implementation does not support pushing.
* (server side) repository. Object files are retrieved directly through
* standard HTTP GET requests, making it easy to serve a Git repository through
* a standard web host provider that does not offer specific support for Git.
- *
+ *
* @see WalkFetchConnection
*/
public class TransportHttp extends HttpTransport implements WalkTransport {
* <p>
* Concurrent pushing over this transport is not supported. Multiple concurrent
* push operations may cause confusion in the repository state.
- *
+ *
* @see WalkFetchConnection
*/
public class TransportSftp extends SshTransport implements WalkTransport {
/**
* Parse and construct an {@link URIish} from a string
- *
+ *
* @param s
* @throws URISyntaxException
*/
/**
* Return a new URI matching this one, but with a different host.
- *
+ *
* @param n
* the new value for host.
* @return a new URI with the updated value.
/**
* Return a new URI matching this one, but with a different scheme.
- *
+ *
* @param n
* the new value for scheme.
* @return a new URI with the updated value.
/**
* Return a new URI matching this one, but with a different path.
- *
+ *
* @param n
* the new value for path.
* @return a new URI with the updated value.
/**
* Return a new URI matching this one, but with a different user.
- *
+ *
* @param n
* the new value for user.
* @return a new URI with the updated value.
/**
* Return a new URI matching this one, but with a different password.
- *
+ *
* @param n
* the new value for password.
* @return a new URI with the updated value.
/**
* Return a new URI matching this one, but with a different port.
- *
+ *
* @param n
* the new value for port.
* @return a new URI with the updated value.
* Instead it delegates the transfer to a {@link WalkRemoteObjectDatabase},
* which knows how to read individual files from the remote repository and
* supply the data as a standard Java InputStream.
- *
+ *
* @see WalkRemoteObjectDatabase
*/
class WalkFetchConnection extends BaseFetchConnection {
switch (obj.getType()) {
case Constants.OBJ_BLOB:
- processBlob(obj);
+ processBlob(obj);
break;
case Constants.OBJ_TREE:
processTree(obj);
case Constants.OBJ_BLOB:
obj.add(COMPLETE);
break;
- case Constants.OBJ_COMMIT:
+ case Constants.OBJ_COMMIT:
pushLocalCommit((RevCommit) obj);
break;
case Constants.OBJ_TREE:
* Pack names should be the file name in the packs directory, that is
* <code>pack-035760ab452d6eebd123add421f253ce7682355a.pack</code>. Index
* names should not be included in the returned collection.
- *
+ *
* @return list of pack names; null or empty list if none are available.
* @throws IOException
* The connection is unable to read the remote repository's list
* <p>
* Alternates may reuse the same network connection handle, however the
* fetch connection will {@link #close()} each created alternate.
- *
+ *
* @return list of additional object databases the caller could fetch from;
* null or empty list if none are configured.
* @throws IOException
* Callers such as {@link WalkFetchConnection} are prepared to handle this
* by validating the content received, and assuming content that fails to
* match its hash is an incorrectly phrased FileNotFoundException.
- *
+ *
* @param path
* location of the file to read, relative to this objects
* directory (e.g.
* This method is typically called by {@link #readAlternates(String)} when
* subclasses us the generic alternate parsing logic for their
* implementation of {@link #getAlternates()}.
- *
+ *
* @param location
* the location of the new alternate, relative to the current
* object database.
* <p>
* This is shorthand for calling {@link #open(String)} and then wrapping it
* in a reader suitable for line oriented files like the alternates list.
- *
+ *
* @return a stream to read from the file. Never null.
* @param path
* location of the file to read, relative to this objects
* <p>
* Alternates appear one per line, with paths expressed relative to this
* object database.
- *
+ *
* @param listPath
* location of the alternate file to read, relative to this
* object database (e.g. <code>info/alternates</code>).
/**
* Create a new stream of unknown length.
- *
+ *
* @param i
* stream containing the file data. This stream will be
* closed by the caller when reading is complete.
/**
* Create a new stream of known length.
- *
+ *
* @param i
* stream containing the file data. This stream will be
* closed by the caller when reading is complete.
* <p>
* WalkTransports are not as efficient as {@link PackTransport} instances, but
* can be useful in situations where a pack transport is not acceptable.
- *
+ *
* @see WalkFetchConnection
*/
public interface WalkTransport {
* In the second item, <code>A</code> is the name of a subtree and
* <code>c</code> is a file within that subtree. The other two items are files
* in the root level tree.
- *
+ *
* @see CanonicalTreeParser
*/
public abstract class AbstractTreeIterator {
* <p>
* A numerical value from FileMode is usually faster for an iterator to
* obtain from its data source so this is the preferred representation.
- *
+ *
* @see org.eclipse.jgit.lib.FileMode
*/
protected int mode;
/**
* Create an iterator for a subtree of an existing iterator.
- *
+ *
* @param p
* parent tree iterator.
*/
/**
* Grow the path buffer larger.
- *
+ *
* @param len
* number of live bytes in the path buffer. This many bytes will
* be moved into the larger buffer.
/**
* Compare the path of this current entry to another iterator's entry.
- *
+ *
* @param p
* the other iterator to compare the path against.
* @return -1 if this entry sorts first; 0 if the entries are equal; 1 if
* This method is faster than {@link #getEntryObjectId()} as it does not
* require copying the bytes out of the buffers. A direct {@link #idBuffer}
* compare operation is performed.
- *
+ *
* @param otherIterator
* the other iterator to test against.
* @return true if both iterators have the same object id; false otherwise.
/**
* Get the object id of the current entry.
- *
+ *
* @return an object id for the current entry.
*/
public ObjectId getEntryObjectId() {
* all entries, or it can be a unique buffer per-entry. Implementations are
* encouraged to expose their private buffer whenever possible to reduce
* garbage generation and copying costs.
- *
+ *
* @return byte array the implementation stores object IDs within.
* @see #getEntryObjectId()
*/
/**
* Get the position within {@link #idBuffer()} of this entry's ObjectId.
- *
+ *
* @return offset into the array returned by {@link #idBuffer()} where the
* ObjectId must be copied out of.
*/
* The parent reference of the iterator must be <code>this</code>,
* otherwise the caller would not be able to exit out of the subtree
* iterator correctly and return to continue walking <code>this</code>.
- *
+ *
* @param repo
* repository to load the tree data from.
* @return a new parser that walks over the current subtree.
* Is this tree iterator at its EOF point (no more entries)?
* <p>
* An iterator is at EOF if there is no current entry.
- *
+ *
* @return true if we have walked all entries and have none left.
*/
public abstract boolean eof();
* as well as any implementation dependent information necessary to
* accurately return data from {@link #idBuffer()} and {@link #idOffset()}
* when demanded.
- *
+ *
* @param delta
* number of entries to move the iterator by. Must be a positive,
* non-zero integer.
/**
* Reset this parser to walk through the given tree data.
- *
+ *
* @param treeData
* the raw tree content.
*/
/**
* Reset this parser to walk through the given tree.
- *
+ *
* @param repo
* repository to load the tree data from.
* @param id
/**
* Create a new iterator to traverse the given directory and its children.
- *
+ *
* @param root
* the starting directory. This directory should correspond to
* the root of the repository.
/**
* Create a new iterator to traverse a subdirectory.
- *
+ *
* @param p
* the parent iterator we were created from.
* @param root
* The returned tree walk is already positioned on the requested path, so
* the caller should not need to invoke {@link #next()} unless they are
* looking for a possible directory/file name conflict.
- *
+ *
* @param db
* repository to read tree object data from.
* @param path
* The returned tree walk is already positioned on the requested path, so
* the caller should not need to invoke {@link #next()} unless they are
* looking for a possible directory/file name conflict.
- *
+ *
* @param db
* repository to read tree object data from.
* @param path
/**
* Create a new tree walker for a given repository.
- *
+ *
* @param repo
* the repository the walker will obtain data from.
*/
/**
* Get the repository this tree walker is reading from.
- *
+ *
* @return the repository configured when the walker was created.
*/
public Repository getRepository() {
/**
* Get the currently configured filter.
- *
+ *
* @return the current filter. Never null as a filter is always needed.
*/
public TreeFilter getFilter() {
* filter, unless the filter implementation specifically states it is (and
* always will be) thread-safe. Callers may use {@link TreeFilter#clone()}
* to create a unique filter tree for this TreeWalk instance.
- *
+ *
* @param newFilter
* the new filter. If null the special {@link TreeFilter#ALL}
* filter will be used instead, as it matches every entry.
* <p>
* If the walker is recursive then the caller will not see a subtree node
* and instead will only receive file nodes in all relevant subtrees.
- *
+ *
* @return true if automatically entering subtrees is enabled.
*/
public boolean isRecursive() {
* (directory) is deleted then all of the file level nodes will appear to be
* deleted, recursively, through as many levels as necessary to account for
* all entries.
- *
+ *
* @param b
* true to skip subtree nodes and only obtain files nodes.
*/
/**
* Reset this walker to run over a set of existing trees.
- *
+ *
* @param ids
* the trees we need to parse. The walker will execute over this
* many parallel trees if the reset is successful.
* has lost track of the order they added the trees into the walker.
* <p>
* The tree must have the same root as existing trees in the walk.
- *
+ *
* @param id
* identity of the tree object the caller wants walked.
* @return position of this tree within the walker.
* <p>
* The tree which the iterator operates on must have the same root as
* existing trees in the walk.
- *
+ *
* @param p
* an iterator to walk over. The iterator should be new, with no
* parent, and should still be positioned before the first entry.
/**
* Get the number of trees known to this walker.
- *
+ *
* @return the total number of trees this walker is iterating over.
*/
public int getTreeCount() {
/**
* Advance this walker to the next relevant entry.
- *
+ *
* @return true if there is an entry available; false if all entries have
* been walked and the walk of this set of tree iterators is over.
* @throws MissingObjectException
* Every added tree supplies mode bits, even if the tree does not contain
* the current entry. In the latter case {@link FileMode#MISSING}'s mode
* bits (0) are returned.
- *
+ *
* @param nth
* tree to obtain the mode bits from.
* @return mode bits for the current entry of the nth tree.
* <p>
* Every added tree supplies a mode, even if the tree does not contain the
* current entry. In the latter case {@link FileMode#MISSING} is returned.
- *
+ *
* @param nth
* tree to obtain the mode from.
* @return mode for the current entry of the nth tree.
* <p>
* Every tree supplies an object id, even if the tree does not contain the
* current entry. In the latter case {@link ObjectId#zeroId()} is returned.
- *
+ *
* @param nth
* tree to obtain the object identifier from.
* @return object identifier for the current tree entry.
/**
* Compare two tree's current ObjectId values for equality.
- *
+ *
* @param nthA
* first tree to compare the object id from.
* @param nthB
* and final output generation. Applications should try to avoid calling it,
* and if invoked do so only once per interesting entry, where the name is
* absolutely required for correct function.
- *
+ *
* @return complete path of the current entry, from the root of the
* repository. If the current entry is in a subtree there will be at
* least one '/' in the returned string.
* method then to use {@link #getPathString()} to first create a String
* object, then test <code>startsWith</code> or some other type of string
* match function.
- *
+ *
* @param p
* path buffer to test. Callers should ensure the path does not
* end with '/' prior to invocation.
* This method is faster then testing the raw mode bits of all trees to see
* if any of them are a subtree. If at least one is a subtree then this
* method will return true.
- *
+ *
* @return true if {@link #enterSubtree()} will work on the current node.
*/
public boolean isSubtree() {
* <p>
* If the current entry is a subtree this method arranges for its children
* to be returned before the next sibling following the subtree is returned.
- *
+ *
* @throws MissingObjectException
* a subtree was found, but the subtree object does not exist in
* this repository. The repository may be missing objects.
* <code>java.io</code> package. Plugins for a Java based IDE may however wish
* to create their own implementations of this class to allow traversal of the
* IDE's project space, as well as benefit from any caching the IDE may have.
- *
+ *
* @see FileTreeIterator
*/
public abstract class WorkingTreeIterator extends AbstractTreeIterator {
/**
* Create an iterator for a subtree of an existing iterator.
- *
+ *
* @param p
* parent tree iterator.
*/
/**
* Obtain the current entry from this iterator.
- *
+ *
* @return the currently selected entry.
*/
protected Entry current() {
* The implementation of this method must be efficient. If a subclass
* needs to compute the value they should cache the reference within an
* instance member instead.
- *
+ *
* @return a file mode constant from {@link FileMode}.
*/
public abstract FileMode getMode();
* The implementation of this method must be efficient. If a subclass
* needs to compute the value they should cache the reference within an
* instance member instead.
- *
+ *
* @return size of this file, in bytes.
*/
public abstract long getLength();
* <p>
* Efficient implementations are not required. The caller will obtain
* the name only once and cache it once obtained.
- *
+ *
* @return name of the entry.
*/
public abstract String getName();
* block IO operations.
* <p>
* The caller will close the stream once complete.
- *
+ *
* @return a stream to read from the file.
* @throws IOException
* the file could not be opened for reading.
public abstract class AndTreeFilter extends TreeFilter {
/**
* Create a filter with two filters, both of which must match.
- *
+ *
* @param a
* first filter to test.
* @param b
/**
* Create a filter around many filters, all of which must match.
- *
+ *
* @param list
* list of filters to match against. Must contain at least 2
* filters.
/**
* Create a filter around many filters, all of which must match.
- *
+ *
* @param list
* list of filters to match against. Must contain at least 2
* filters.
public class NotTreeFilter extends TreeFilter {
/**
* Create a filter that negates the result of another filter.
- *
+ *
* @param a
* filter to negate.
* @return a filter that does the reverse of <code>a</code>.
public abstract class OrTreeFilter extends TreeFilter {
/**
* Create a filter with two filters, one of which must match.
- *
+ *
* @param a
* first filter to test.
* @param b
/**
* Create a filter around many filters, one of which must match.
- *
+ *
* @param list
* list of filters to match against. Must contain at least 2
* filters.
/**
* Create a filter around many filters, one of which must match.
- *
+ *
* @param list
* list of filters to match against. Must contain at least 2
* filters.
* caller must prepend the subdirectory's path prior to creating the filter.
* <p>
* Path strings use '/' to delimit directories on all platforms.
- *
+ *
* @param path
* the path to filter on. Must not be the empty string. All
* trailing '/' characters will be trimmed before string's length
* Paths may appear in any order within the collection. Sorting may be done
* internally when the group is constructed if doing so will improve path
* matching performance.
- *
+ *
* @param paths
* the paths to test against. Must have at least one entry.
* @return a new filter for the list of paths supplied.
* Paths may appear in any order within the collection. Sorting may be done
* internally when the group is constructed if doing so will improve path
* matching performance.
- *
+ *
* @param paths
* the paths to test against. Must have at least one entry.
* @return a new filter for the list of paths supplied.
* their instances during {@link #include(TreeWalk)} if it is beneficial to
* their implementation. Deep clones created by {@link #clone()} may be used to
* construct a thread-safe copy of an existing filter.
- *
+ *
* <p>
* <b>Path filters:</b>
* <ul>
* <li>Matching pathname: {@link PathFilter}</li>
* </ul>
- *
+ *
* <p>
* <b>Difference filters:</b>
* <ul>
* <li>Only select differences: {@link #ANY_DIFF}.</li>
* </ul>
- *
+ *
* <p>
* <b>Boolean modifiers:</b>
* <ul>
/**
* Create a new filter that does the opposite of this filter.
- *
+ *
* @return a new filter that includes tree entries this filter rejects.
*/
public TreeFilter negate() {
* {@link TreeWalk#isRecursive()} is enabled. The consultation allows the
* filter to bypass subtree recursion on a case-by-case basis, even when
* recursion is enabled at the application level.
- *
+ *
* @param walker
* the walker the filter needs to examine.
* @return true if the current entry should be seen by the application;
* is looking for a '/' then the filter would require a recursive TreeWalk
* to accurately make its decisions. The walker is not required to enable
* recursive behavior for any particular filter, this is only a hint.
- *
+ *
* @return true if the filter would like to have the walker recurse into
* subtrees to make sure it matches everything correctly; false if
* the filter does not require entering subtrees.
* <p>
* This is a deep clone. If this filter embeds objects or other filters it
* must also clone those, to ensure the instances do not share mutable data.
- *
+ *
* @return another copy of this filter, suitable for another thread.
*/
public abstract TreeFilter clone();
/**
* Does this operating system and JRE support the execute flag on files?
- *
+ *
* @return true if this implementation can provide reasonably accurate
* executable bit information; false otherwise.
*/
* <p>
* Not all platforms and JREs support executable flags on files. If the
* feature is unsupported this method will always return false.
- *
+ *
* @param f
* abstract path to test.
* @return true if the file is believed to be executable by the user.
* Not all platforms and JREs support executable flags on files. If the
* feature is unsupported this method will always return false and no
* changes will be made to the file specified.
- *
+ *
* @param f
* path to modify the executable status of.
* @param canExec
* <p>
* Not all platforms and JREs require path name translation. Currently only
* Cygwin on Win32 require translation for Cygwin based paths.
- *
+ *
* @param dir
* directory relative to which the path name is.
* @param name
* <p>
* Not all platforms and JREs require path name translation. Currently only
* Cygwin on Win32 require translation for Cygwin based paths.
- *
+ *
* @param dir
* directory relative to which the path name is.
* @param name
* <p>
* Not all platforms and JREs require path name translation. Currently only
* Cygwin on Win32 requires translation of the Cygwin HOME directory.
- *
+ *
* @return the user's home directory; null if the user does not have one.
*/
public static File userHome() {
/**
* Determine the user's home directory (location where preferences are).
- *
+ *
* @return the user's home directory; null if the user does not have one.
*/
protected File userHomeImpl() {
public boolean setExecute(final File f, final boolean canExec) {
return false;
}
-}
\ No newline at end of file
+}
/**
* Read the entire byte array into memory, or throw an exception.
- *
+ *
* @param fd
* input stream to read the data from.
* @param dst
* This function performs an unsigned compare operation, even though Java
* does not natively support unsigned integer values. Negative numbers are
* treated as larger than positive ones.
- *
+ *
* @param a
* the first value to compare.
* @param b
/**
* Convert sequence of 4 bytes (network byte order) into signed value.
- *
+ *
* @param intbuf
* buffer to acquire the 4 bytes of data from.
* @param offset
/**
* Convert sequence of 4 bytes (network byte order) into unsigned value.
- *
+ *
* @param intbuf
* buffer to acquire the 4 bytes of data from.
* @param offset
/**
* Convert sequence of 8 bytes (network byte order) into unsigned value.
- *
+ *
* @param intbuf
* buffer to acquire the 8 bytes of data from.
* @param offset
/**
* Write a 32 bit integer as a sequence of 4 bytes (network byte order).
- *
+ *
* @param intbuf
* buffer to write the 4 bytes of data into.
* @param offset
b.append(charAt(i));
return b.toString();
}
-}
\ No newline at end of file
+}
* The argument and return values from this method make it easy to chain
* writing, for example:
* </p>
- *
+ *
* <pre>
* final byte[] tmp = new byte[64];
* int ptr = tmp.length;
* tmp[--ptr] = 0;
* final String str = new String(tmp, ptr, tmp.length - ptr);
* </pre>
- *
+ *
* @param b
* buffer to write into.
* @param o
* sequence, and may start with a '+' or a '-' to indicate sign position.
* Any other characters will cause the method to stop and return the current
* result to the caller.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
* sequence, and may start with a '+' or a '-' to indicate sign position.
* Any other characters will cause the method to stop and return the current
* result to the caller.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
* <p>
* The sequence "-0315" will be parsed as the numeric value -195, as the
* lower two positions count minutes, not 100ths of an hour.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
/**
* Locate the first position after a given character.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
* Locate the first position after either the given character or LF.
* <p>
* This method stops on the first match it finds from either chrA or '\n'.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
/**
* Locate the "author " header line data.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
/**
* Locate the "committer " header line data.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
/**
* Locate the "encoding " header line.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
* to apply to this buffer to evaluate its contents as character data.
* <p>
* If no encoding header is present, {@link Constants#CHARSET} is assumed.
- *
+ *
* @param b
* buffer to scan.
* @return the Java character set representation. Never null.
* return value of {@link #author(byte[], int)} or
* {@link #committer(byte[], int)}, as these methods provide the proper
* position within the buffer.
- *
+ *
* @param raw
* the buffer to parse character data from.
* @param nameB
*
* If the byte stream cannot be decoded that way, the platform default is tried
* and if that too fails, the fail-safe ISO-8859-1 encoding is tried.
- *
+ *
* @param buffer
* buffer to pull raw bytes from.
* @return a string representation of the range <code>[start,end)</code>,
*
* If the byte stream cannot be decoded that way, the platform default is tried
* and if that too fails, the fail-safe ISO-8859-1 encoding is tried.
- *
+ *
* @param cs
* character set to use when decoding the buffer.
* @param buffer
*
* If the byte stream cannot be decoded that way, the platform default is tried
* and if that too fails, the fail-safe ISO-8859-1 encoding is tried.
- *
+ *
* @param cs
* character set to use when decoding the buffer.
* @param buffer
/**
* Locate the position of the commit message body.
- *
+ *
* @param b
* buffer to scan.
* @param ptr
* Locate the end of a paragraph.
* <p>
* A paragraph is ended by two consecutive LF bytes.
- *
+ *
* @param b
* buffer to scan.
* @param start
/**
* Construct a new substring pattern.
- *
+ *
* @param patternText
* text to locate. This should be a literal string, as no
* meta-characters are supported by this implementation. The
/**
* Match a character sequence against this pattern.
- *
+ *
* @param rcs
* the sequence to match. Must not be null but the length of the
* sequence is permitted to be 0.
/**
* Get the literal pattern string this instance searches for.
- *
+ *
* @return the pattern string given to our constructor.
*/
public String pattern() {