diff options
author | Stefan Lay <stefan.lay@sap.com> | 2010-11-30 11:33:54 +0100 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-11-30 10:51:21 -0800 |
commit | b4359cb8294de1e80147f00caabad9ebd6b7bce1 (patch) | |
tree | c9c1fbe056065854b1f86f1f54de31cbbbbf29c9 /org.eclipse.jgit.test | |
parent | 7bf0f5070e977d716fbce9309266bb7c26be0a74 (diff) | |
download | jgit-b4359cb8294de1e80147f00caabad9ebd6b7bce1.tar.gz jgit-b4359cb8294de1e80147f00caabad9ebd6b7bce1.zip |
Include list of assume unchanged files in IndexDiff
The IndexDiff had not collected the info if the flag
"assume-unchanged" is set. This information is useful for clients
which may want to decide if specific actions are allowed on a file.
Bug: 326213
Change-Id: I14bb7b03247d6c0b429a9d8d3f6b10f21d8ddeb1
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java index c73764a990..0ce85b4be0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java @@ -51,6 +51,7 @@ import java.io.IOException; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; +import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.treewalk.FileTreeIterator; public class IndexDiffTest extends RepositoryTestCase { @@ -234,6 +235,39 @@ public class IndexDiffTest extends RepositoryTestCase { assertTrue(diff.getUntracked().contains(path)); } + public void testAssumeUnchanged() throws Exception { + Git git = new Git(db); + String path = "file"; + writeTrashFile(path, "content"); + git.add().addFilepattern(path).call(); + String path2 = "file2"; + writeTrashFile(path2, "content"); + git.add().addFilepattern(path2).call(); + git.commit().setMessage("commit").call(); + assumeUnchanged(path2); + writeTrashFile(path, "more content"); + writeTrashFile(path2, "more content"); + + FileTreeIterator iterator = new FileTreeIterator(db); + IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator); + diff.diff(); + assertEquals(1, diff.getAssumeUnchanged().size()); + assertEquals(2, diff.getModified().size()); + assertEquals(0, diff.getChanged().size()); + + git.add().addFilepattern(".").call(); + + iterator = new FileTreeIterator(db); + diff = new IndexDiff(db, Constants.HEAD, iterator); + diff.diff(); + assertEquals(1, diff.getAssumeUnchanged().size()); + assertEquals(1, diff.getModified().size()); + assertEquals(1, diff.getChanged().size()); + assertTrue(diff.getAssumeUnchanged().contains("file2")); + assertTrue(diff.getModified().contains("file2")); + assertTrue(diff.getChanged().contains("file")); + } + private void removeFromIndex(String path) throws IOException { final DirCache dirc = db.lockDirCache(); final DirCacheEditor edit = dirc.editor(); @@ -241,4 +275,15 @@ public class IndexDiffTest extends RepositoryTestCase { if (!edit.commit()) throw new IOException("could not commit"); } + + 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"); + } + } |