From c75aa1aed238dd62d6f00958a5fb2cf782349ee1 Mon Sep 17 00:00:00 2001 From: Tomasz Zarna Date: Sun, 18 Mar 2012 01:13:01 +0100 Subject: [PATCH] LogCommand#setMaxCount affects all commits Bug: 370132 Change-Id: I9f5ff3640a4f69c0b48c97609728d7672e63e6ab Signed-off-by: Matthias Sohn Signed-off-by: Chris Aniszczyk --- .../org/eclipse/jgit/api/LogCommandTest.java | 36 ++++++++++++++++--- .../eclipse/jgit/revwalk/StartGenerator.java | 2 +- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java index b9af9dc608..b9dc4265d0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java @@ -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 commits = createCommits(git); + + Iterator 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 commits = createCommits(git); + + Iterator 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); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java index 869c0e1d94..5b264fcf3d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java @@ -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; } -- 2.39.5