aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java42
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java5
2 files changed, 47 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
index 68007b6cff..4357f8b0c1 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
@@ -456,6 +456,38 @@ public class AddCommandTest extends RepositoryTestCase {
indexState(CONTENT));
}
+ public void testAssumeUnchanged() throws Exception {
+ Git git = new Git(db);
+ String path = "a.txt";
+ writeTrashFile(path, "content");
+ git.add().addFilepattern(path).call();
+ String path2 = "b.txt";
+ writeTrashFile(path2, "content");
+ git.add().addFilepattern(path2).call();
+ git.commit().setMessage("commit").call();
+ assertEquals("[a.txt, mode:100644, content:"
+ + "content, assume-unchanged:false]"
+ + "[b.txt, mode:100644, content:content, "
+ + "assume-unchanged:false]", indexState(CONTENT
+ | ASSUME_UNCHANGED));
+ assumeUnchanged(path2);
+ assertEquals("[a.txt, mode:100644, content:content, "
+ + "assume-unchanged:false][b.txt, mode:100644, "
+ + "content:content, assume-unchanged:true]", indexState(CONTENT
+ | ASSUME_UNCHANGED));
+ writeTrashFile(path, "more content");
+ writeTrashFile(path2, "more content");
+
+ git.add().addFilepattern(".").call();
+
+ assertEquals("[a.txt, mode:100644, content:more content,"
+ + " assume-unchanged:false][b.txt, mode:100644,"
+ + "" + ""
+ + " content:content, assume-unchanged:true]",
+ indexState(CONTENT
+ | ASSUME_UNCHANGED));
+ }
+
private DirCacheEntry addEntryToBuilder(String path, File file,
ObjectInserter newObjectInserter, DirCacheBuilder builder, int stage)
throws IOException {
@@ -473,4 +505,14 @@ public class AddCommandTest extends RepositoryTestCase {
return entry;
}
+ private void assumeUnchanged(String path) throws IOException {
+ final DirCache dirc = db.lockDirCache();
+ final DirCacheEntry ent = dirc.getEntry(path);
+ if (ent != null)
+ ent.setAssumeValid(true);
+ dirc.write();
+ if (!dirc.commit())
+ throw new IOException("could not commit");
+ }
+
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java
index 409fabf8f3..30cec12798 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java
@@ -138,6 +138,8 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
public static final int CONTENT = 16;
+ public static final int ASSUME_UNCHANGED = 32;
+
/**
* Represent the state of the index in one String. This representation is
* useful when writing tests which do assertions on the state of the index.
@@ -209,6 +211,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
+ new String(db.open(entry.getObjectId(),
Constants.OBJ_BLOB).getCachedBytes(), "UTF-8"));
}
+ if (0 != (includedOptions & ASSUME_UNCHANGED))
+ sb.append(", assume-unchanged:"
+ + Boolean.toString(entry.isAssumeValid()));
sb.append("]");
}
return sb.toString();