]> source.dussan.org Git - jgit.git/commitdiff
LogCommand#setMaxCount affects all commits 28/5028/4
authorTomasz Zarna <Tomasz.Zarna@pl.ibm.com>
Sun, 18 Mar 2012 00:13:01 +0000 (01:13 +0100)
committerChris Aniszczyk <zx@twitter.com>
Sun, 18 Mar 2012 13:08:35 +0000 (08:08 -0500)
Bug: 370132
Change-Id: I9f5ff3640a4f69c0b48c97609728d7672e63e6ab
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java

index b9af9dc608a5721ea8a2464f103d91e2ee6cfcfc..b9dc4265d053b4235ab083ffd1b5d7edc8c4a3c1 100644 (file)
@@ -94,11 +94,11 @@ public class LogCommandTest extends RepositoryTestCase {
                writeTrashFile("Test.txt", "Hello world");
                git.add().addFilepattern("Test.txt").call();
                commits.add(git.commit().setMessage("commit#1").call());
-               writeTrashFile("Test1.txt", "Hello world!");
-               git.add().addFilepattern("Test1.txt").call();
+               writeTrashFile("Test.txt", "Hello world!");
+               git.add().addFilepattern("Test.txt").call();
                commits.add(git.commit().setMessage("commit#2").call());
-               writeTrashFile("Test2.txt", "Hello world!!");
-               git.add().addFilepattern("Test2.txt").call();
+               writeTrashFile("Test1.txt", "Hello world!!");
+               git.add().addFilepattern("Test1.txt").call();
                commits.add(git.commit().setMessage("commit#3").call());
                return commits;
        }
@@ -121,6 +121,34 @@ public class LogCommandTest extends RepositoryTestCase {
                assertFalse(log.hasNext());
        }
 
+       @Test
+       public void logPathWithMaxCount() throws Exception {
+               Git git = Git.wrap(db);
+               List<RevCommit> commits = createCommits(git);
+
+               Iterator<RevCommit> log = git.log().addPath("Test.txt").setMaxCount(1)
+                               .call().iterator();
+               assertTrue(log.hasNext());
+               RevCommit commit = log.next();
+               assertTrue(commits.contains(commit));
+               assertEquals("commit#2", commit.getShortMessage());
+               assertFalse(log.hasNext());
+       }
+
+       @Test
+       public void logPathWithSkip() throws Exception {
+               Git git = Git.wrap(db);
+               List<RevCommit> commits = createCommits(git);
+
+               Iterator<RevCommit> log = git.log().addPath("Test.txt").setSkip(1)
+                               .call().iterator();
+               assertTrue(log.hasNext());
+               RevCommit commit = log.next();
+               assertTrue(commits.contains(commit));
+               assertEquals("commit#1", commit.getShortMessage());
+               assertFalse(log.hasNext());
+       }
+
        @Test
        public void logAllCommitsWithSkip() throws Exception {
                Git git = Git.wrap(db);
index 869c0e1d94da4d9e4fd5a98d4b8c94196c5349c4..5b264fcf3dff787e49f7378d526db12f69d9f4ad 100644 (file)
@@ -127,7 +127,7 @@ class StartGenerator extends Generator {
                else
                        pending = new DateRevQueue(q);
                if (tf != TreeFilter.ALL) {
-                       rf = AndRevFilter.create(rf, new RewriteTreeFilter(w, tf));
+                       rf = AndRevFilter.create(new RewriteTreeFilter(w, tf), rf);
                        pendingOutputType |= HAS_REWRITE | NEEDS_REWRITE;
                }