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

writeTrashFile("Test.txt", "Hello world"); writeTrashFile("Test.txt", "Hello world");
git.add().addFilepattern("Test.txt").call(); git.add().addFilepattern("Test.txt").call();
commits.add(git.commit().setMessage("commit#1").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()); 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()); commits.add(git.commit().setMessage("commit#3").call());
return commits; return commits;
} }
assertFalse(log.hasNext()); 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 @Test
public void logAllCommitsWithSkip() throws Exception { public void logAllCommitsWithSkip() throws Exception {
Git git = Git.wrap(db); Git git = Git.wrap(db);

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java View File

else else
pending = new DateRevQueue(q); pending = new DateRevQueue(q);
if (tf != TreeFilter.ALL) { 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; pendingOutputType |= HAS_REWRITE | NEEDS_REWRITE;
} }



Loading…
Cancel
Save