View Javadoc
1   /*
2    * Copyright (C) 2009, Google Inc.
3    * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
4    *
5    * This program and the accompanying materials are made available under the
6    * terms of the Eclipse Distribution License v. 1.0 which is available at
7    * https://www.eclipse.org/org/documents/edl-v10.php.
8    *
9    * SPDX-License-Identifier: BSD-3-Clause
10   */
11  
12  package org.eclipse.jgit.revwalk;
13  
14  import java.io.IOException;
15  
16  import org.eclipse.jgit.errors.IncorrectObjectTypeException;
17  import org.eclipse.jgit.errors.MissingObjectException;
18  
19  /**
20   * Filters out commits marked {@link RevWalk#UNINTERESTING}.
21   * <p>
22   * This generator is only in front of another generator that has fully buffered
23   * commits, such that we are called only after the {@link PendingGenerator} has
24   * exhausted its input queue and given up. It skips over any uninteresting
25   * commits that may have leaked out of the PendingGenerator due to clock skew
26   * being detected in the commit objects.
27   */
28  final class FixUninterestingGenerator extends Generator {
29  	private final Generator pending;
30  
31  	FixUninterestingGenerator(Generator g) {
32  		super(g.firstParent);
33  		pending = g;
34  	}
35  
36  	@Override
37  	int outputType() {
38  		return pending.outputType();
39  	}
40  
41  	@Override
42  	RevCommit next() throws MissingObjectException,
43  			IncorrectObjectTypeException, IOException {
44  		for (;;) {
45  			final RevCommit c = pending.next();
46  			if (c == null)
47  				return null;
48  			if ((c.flags & RevWalk.UNINTERESTING) == 0)
49  				return c;
50  		}
51  	}
52  }