theonedev/onedev · error · IllegalStateException

Cannot combine TreeFilter {0} with RevFilter {1}.

Error message

Cannot combine TreeFilter {0} with RevFilter {1}.

What it means

This IllegalStateException is thrown by StartGenerator.next() when a revision walk is configured with RevFilter.MERGE_BASE (a merge-base computation) and a TreeFilter other than TreeFilter.ALL. Merge-base computation is a special pipeline that ignores tree/path filters, so any non-ALL filter would be silently ignored — JGit refuses instead. Fix the configuration before calling RevWalk.next().

Source

Thrown at server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java:61

		return 0;
	}

	@Override
	RevCommit next() throws MissingObjectException,
			IncorrectObjectTypeException, IOException {
		Generator g;

		final RevWalk w = walker;
		RevFilter rf = w.getRevFilter();
		final TreeFilter tf = w.getTreeFilter();
		AbstractRevQueue q = walker.queue;

		if (rf == RevFilter.MERGE_BASE) {
			// Computing for merge bases is a special case and does not
			// use the bulk of the generator pipeline.
			//
			if (tf != TreeFilter.ALL) {
				throw new IllegalStateException(MessageFormat.format(
						JGitText.get().cannotCombineTreeFilterWithRevFilter, tf, rf));
			}
			if (w.isFirstParent()) {
				throw new IllegalStateException(
						JGitText.get().cannotFindMergeBaseUsingFirstParent);
			}

			final MergeBaseGenerator mbg = new MergeBaseGenerator(w);
			walker.pending = mbg;
			walker.queue = AbstractRevQueue.EMPTY_QUEUE;
			mbg.init(q);
			return mbg.next();
		}

		final boolean uninteresting = q.anybodyHasFlag(RevWalk.UNINTERESTING);
		boolean boundary = walker.hasRevSort(RevSort.BOUNDARY);

		if (!boundary && walker instanceof ObjectWalk) {

View on GitHub (pinned to d44925c47c)

Solutions

  1. Remove the setTreeFilter() call, or explicitly call walker.setTreeFilter(TreeFilter.ALL) before iterating
  2. Use a separate RevWalk instance for merge-base computation, isolated from path-filtered walks
  3. If path restriction is needed, do post-filtering of merge-base results after the walk completes

Example fix

// before
RevWalk walk = new RevWalk(repo);
walk.setTreeFilter(AndTreeFilter.create(PathFilter.create("src/"), TreeFilter.ANY_DIFF));
walk.setRevFilter(RevFilter.MERGE_BASE);
// after
RevWalk walk = new RevWalk(repo);
walk.setTreeFilter(TreeFilter.ALL);
walk.setRevFilter(RevFilter.MERGE_BASE);
Defensive patterns

Strategy: validation

Validate before calling

if (walk.getRevFilter() == RevFilter.MERGE_BASE && walk.getTreeFilter() != TreeFilter.ALL) {
    walk.setTreeFilter(TreeFilter.ALL); // or use a separate walk
}

Try / catch

try (RevWalk walk = new RevWalk(repo)) {
    ...
} catch (IllegalStateException e) {
    // reconfigure walk: clear TreeFilter or drop MERGE_BASE filter, then retry
}

Prevention

When it happens

Trigger: Calling RevWalk.setRevFilter(RevFilter.MERGE_BASE) while also having called setTreeFilter() with anything other than TreeFilter.ALL (including ANY_DIFF or a path filter), then iterating the walk.

Common situations: Developers trying to compute merge bases while also limiting the walk to specific paths; code copied from a normal log walk that already had a TreeFilter set and later switches to merge-base mode.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/fa58f7da249ddcfe. Report an issue: GitHub.