Browse Source

LogCommand#setMaxCount affects all commits

Bug: 370132
Change-Id: I9f5ff3640a4f69c0b48c97609728d7672e63e6ab
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
tags/v2.0.0.201206130900-r
Tomasz Zarna 12 years ago
parent
commit
c75aa1aed2

+ 32
- 4
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java View 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);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java View 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;
}


Loading…
Cancel
Save