The Unified and Autonomous Development Platform
Merge branch 'stable'
Robin Shen27c4120c6a71
diff --cc server-core/src/main/java/org/eclipse/jgit/revwalk/AsyncRevObjectQueue.javaindex d263184622,d263184622..98654f14c2--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/AsyncRevObjectQueue.java+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/AsyncRevObjectQueue.java@@@ -66,5 -66,5 +66,5 @@@ public interface AsyncRevObjectQueue ex* @throws java.io.IOException* the object store cannot be accessed.*/-- public RevObject next() throws MissingObjectException, IOException;++ RevObject next() throws MissingObjectException, IOException;}diff --cc server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.javaindex eaec305b47,eaec305b47..5154920393--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.java+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.java@@@ -48,6 -48,6 +48,7 @@@ import java.io.IOExceptionimport org.eclipse.jgit.errors.IncorrectObjectTypeException;import org.eclipse.jgit.errors.MissingObjectException;++import org.eclipse.jgit.lib.ObjectId;/*** Only produce commits which are below a specified depth.@@@ -59,6 -59,6 +60,8 @@@ class DepthGenerator extends Generatorprivate final int depth;++ private final int deepenSince;++private final RevWalk walk;/**@@@ -78,6 -78,6 +81,11 @@@*/private final RevFlag REINTERESTING;++ /**++ * Commits reachable from commits that the client specified using --shallow-exclude.++ */++ private final RevFlag DEEPEN_NOT;++/*** @param w* @param s Parent generator@@@ -91,8 -91,8 +99,10 @@@walk = (RevWalk)w;this.depth = w.getDepth();++ this.deepenSince = w.getDeepenSince();this.UNSHALLOW = w.getUnshallowFlag();this.REINTERESTING = w.getReinterestingFlag();++ this.DEEPEN_NOT = w.getDeepenNotFlag();s.shareFreeList(pending);@@@ -105,6 -105,6 +115,37 @@@if (((DepthWalk.Commit) c).getDepth() == 0)pending.add(c);}++++ // Mark DEEPEN_NOT on all deepen-not commits and their ancestors.++ // TODO(jonathantanmy): This implementation is somewhat++ // inefficient in that any "deepen-not <ref>" in the request++ // results in all commits reachable from that ref being parsed++ // and marked, even if the commit topology is such that it is++ // not necessary.++ for (ObjectId oid : w.getDeepenNots()) {++ RevCommit c;++ try {++ c = walk.parseCommit(oid);++ } catch (IncorrectObjectTypeException notCommit) {++ // The C Git implementation silently tolerates++ // non-commits, so do the same here.++ continue;++ }++++ FIFORevQueue queue = new FIFORevQueue();++ queue.add(c);++ while ((c = queue.next()) != null) {++ if (c.has(DEEPEN_NOT)) {++ continue;++ }++++ walk.parseHeaders(c);++ c.add(DEEPEN_NOT);++ for (RevCommit p : c.getParents()) {++ queue.add(p);++ }++ }++ }}@Override@@@ -132,6 -132,6 +173,14 @@@if ((c.flags & RevWalk.PARSED) == 0)c.parseHeaders(walk);++ if (c.getCommitTime() < deepenSince) {++ continue;++ }++++ if (c.has(DEEPEN_NOT)) {++ continue;++ }++int newDepth = c.depth + 1;for (RevCommit p : c.parents) {@@@ -142,12 -142,12 +191,29 @@@// this depth is guaranteed to be the smallest value that// any path could produce.if (dp.depth == -1) {++ boolean failsDeepenSince = false;++ if (deepenSince != 0) {++ if ((p.flags & RevWalk.PARSED) == 0) {++ p.parseHeaders(walk);++ }++ failsDeepenSince =++ p.getCommitTime() < deepenSince;++ }++dp.depth = newDepth;-- // If the parent is not too deep, add it to the queue-- // so that we can produce it later-- if (newDepth <= depth)++ // If the parent is not too deep and was not excluded, add++ // it to the queue so that we can produce it later++ if (newDepth <= depth && !failsDeepenSince &&++ !p.has(DEEPEN_NOT)) {pending.add(p);++ } else {++ dp.makesChildBoundary = true;++ }++ }++++ if (dp.makesChildBoundary) {++ c.isBoundary = true;}// If the current commit has become unshallowed, everything@@@ -160,8 -160,8 +226,7 @@@}}-- // Produce all commits less than the depth cutoff-- boolean produce = c.depth <= depth;++ boolean produce = true;// Unshallow commits are uninteresting, but still need to be sent// up to the PackWriter so that it will exclude objects correctly.@@@ -169,6 -169,6 +234,10 @@@if ((c.flags & RevWalk.UNINTERESTING) != 0 && !c.has(UNSHALLOW))produce = false;++ if (c.getCommitTime() < deepenSince) {++ produce = false;++ }++if (produce)return c;}diff --cc server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.javaindex 06a5272b98,06a5272b98..0201f0b602--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.java+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.java@@@ -45,10 -45,10 +45,14 @@@package org.eclipse.jgit.revwalk;import java.io.IOException;++import java.util.Collections;++import java.util.List;++import java.util.Objects;import org.eclipse.jgit.errors.IncorrectObjectTypeException;import org.eclipse.jgit.errors.MissingObjectException;import org.eclipse.jgit.lib.AnyObjectId;++import org.eclipse.jgit.lib.ObjectId;import org.eclipse.jgit.lib.ObjectReader;import org.eclipse.jgit.lib.Repository;@@@ -61,7 -61,7 +65,24 @@@ public interface DepthWalk** @return Depth to filter to.*/-- public int getDepth();++ int getDepth();++++ /**++ * @return the deepen-since value; if not 0, this walk only returns commits++ * whose commit time is at or after this limit++ * @since 5.2++ */++ default int getDeepenSince() {++ return 0;++ }++++ /**++ * @return the objects specified by the client using --shallow-exclude++ * @since 5.2++ */++ default List<ObjectId> getDeepenNots() {++ return Collections.emptyList();++ }/** @return flag marking commits that should become unshallow. *//**@@@ -69,25 -69,25 +90,48 @@@** @return flag marking commits that should become unshallow.*/-- public RevFlag getUnshallowFlag();++ RevFlag getUnshallowFlag();/*** Get flag marking commits that are interesting again.** @return flag marking commits that are interesting again.*/-- public RevFlag getReinterestingFlag();++ RevFlag getReinterestingFlag();++++ /**++ * @return flag marking commits that are to be excluded because of --shallow-exclude++ * @since 5.2++ */++ RevFlag getDeepenNotFlag();/** RevCommit with a depth (in commits) from a root. */public static class Commit extends RevCommit {/** Depth of this commit in the graph, via shortest path. */int depth;++ boolean isBoundary;++++ /**++ * True if this commit was excluded due to a shallow fetch++ * setting. All its children are thus boundary commits.++ */++ boolean makesChildBoundary;++/** @return depth of this commit, as found by the shortest path. */public int getDepth() {return depth;}++ /**++ * @return true if at least one of this commit's parents was excluded++ * due to a shallow fetch setting, false otherwise++ * @since 5.2++ */++ public boolean isBoundary() {++ return isBoundary;++ }++/*** Initialize a new commit.*@@@ -104,10 -104,10 +148,16 @@@public class RevWalk extends org.eclipse.jgit.revwalk.RevWalk implements DepthWalk {private final int depth;++ private int deepenSince;++++ private List<ObjectId> deepenNots;++private final RevFlag UNSHALLOW;private final RevFlag REINTERESTING;++ private final RevFlag DEEPEN_NOT;++/*** @param repo Repository to walk* @param depth Maximum depth to return@@@ -116,8 -116,8 +166,10 @@@super(repo);this.depth = depth;++ this.deepenNots = Collections.emptyList();this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$++ this.DEEPEN_NOT = newFlag("DEEPEN_NOT"); //$NON-NLS-1$}/**@@@ -128,8 -128,8 +180,10 @@@super(or);this.depth = depth;++ this.deepenNots = Collections.emptyList();this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$++ this.DEEPEN_NOT = newFlag("DEEPEN_NOT"); //$NON-NLS-1$}/**@@@ -158,6 -158,6 +212,39 @@@return depth;}++ @Override++ public int getDeepenSince() {++ return deepenSince;++ }++++ /**++ * Sets the deepen-since value.++ *++ * @param limit++ * new deepen-since value++ * @since 5.2++ */++ public void setDeepenSince(int limit) {++ deepenSince = limit;++ }++++ @Override++ public List<ObjectId> getDeepenNots() {++ return deepenNots;++ }++++ /**++ * Mark objects that the client specified using++ * --shallow-exclude. Objects that are not commits have no++ * effect.++ *++ * @param deepenNots specified objects++ * @since 5.2++ */++ public void setDeepenNots(List<ObjectId> deepenNots) {++ this.deepenNots = Objects.requireNonNull(deepenNots);++ }++@Overridepublic RevFlag getUnshallowFlag() {return UNSHALLOW;@@@ -168,12 -168,12 +255,19 @@@return REINTERESTING;}++ @Override++ public RevFlag getDeepenNotFlag() {++ return DEEPEN_NOT;++ }++/*** @since 4.5*/@Overridepublic ObjectWalk toObjectWalkWithSameObjects() {ObjectWalk ow = new ObjectWalk(reader, depth);++ ow.deepenSince = deepenSince;++ ow.deepenNots = deepenNots;ow.objects = objects;ow.freeFlags = freeFlags;return ow;@@@ -184,10 -184,10 +278,16 @@@public class ObjectWalk extends org.eclipse.jgit.revwalk.ObjectWalk implements DepthWalk {private final int depth;++ private int deepenSince;++++ private List<ObjectId> deepenNots;++private final RevFlag UNSHALLOW;private final RevFlag REINTERESTING;++ private final RevFlag DEEPEN_NOT;++/*** @param repo Repository to walk* @param depth Maximum depth to return@@@ -196,8 -196,8 +296,10 @@@super(repo);this.depth = depth;++ this.deepenNots = Collections.emptyList();this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$++ this.DEEPEN_NOT = newFlag("DEEPEN_NOT"); //$NON-NLS-1$}/**@@@ -208,8 -208,8 +310,10 @@@super(or);this.depth = depth;++ this.deepenNots = Collections.emptyList();this.UNSHALLOW = newFlag("UNSHALLOW"); //$NON-NLS-1$this.REINTERESTING = newFlag("REINTERESTING"); //$NON-NLS-1$++ this.DEEPEN_NOT = newFlag("DEEPEN_NOT"); //$NON-NLS-1$}/**@@@ -262,6 -262,6 +366,16 @@@return depth;}++ @Override++ public int getDeepenSince() {++ return deepenSince;++ }++++ @Override++ public List<ObjectId> getDeepenNots() {++ return deepenNots;++ }++@Overridepublic RevFlag getUnshallowFlag() {return UNSHALLOW;@@@ -271,5 -271,5 +385,10 @@@public RevFlag getReinterestingFlag() {return REINTERESTING;}++++ @Override++ public RevFlag getDeepenNotFlag() {++ return DEEPEN_NOT;++ }}}diff --cc server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.javaindex 86ecd8eaee,86ecd8eaee..af4ec1f00b--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.java+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.java@@@ -407,7 -407,7 +407,7 @@@ public class RevCommit extends RevObjec* @return contents of the gpg signature; null if the commit was not signed.* @since 5.1*/-- public final @Nullable byte[] getRawGpgSignature() {++ public final byte[] getRawGpgSignature() {final byte[] raw = buffer;final byte[] header = {'g', 'p', 'g', 's', 'i', 'g'};final int start = RawParseUtils.headerStart(header, raw, 0);diff --cc server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.javaindex 4d555d2178,4d555d2178..400ea33c21--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java@@@ -54,6 -54,6 +54,7 @@@ import java.util.Iteratorimport java.util.List;import org.eclipse.jgit.annotations.NonNull;++import org.eclipse.jgit.annotations.Nullable;import org.eclipse.jgit.errors.CorruptObjectException;import org.eclipse.jgit.errors.IncorrectObjectTypeException;import org.eclipse.jgit.errors.LargeObjectException;@@@ -1335,6 -1335,6 +1336,22 @@@ public class RevWalk implements IterablshallowCommitsInitialized = false;}++ /**++ * Like {@link #next()}, but if a checked exception is thrown during the++ * walk it is rethrown as a {@link RevWalkException}.++ *++ * @throws RevWalkException if an {@link IOException} was thrown.++ * @return next most recent commit; null if traversal is over.++ */++ @Nullable++ private RevCommit nextForIterator() {++ try {++ return next();++ } catch (IOException e) {++ throw new RevWalkException(e);++ }++ }++/*** {@inheritDoc}* <p>@@@ -1353,16 -1353,16 +1370,7 @@@*/@Overridepublic Iterator<RevCommit> iterator() {-- final RevCommit first;-- try {-- first = RevWalk.this.next();-- } catch (MissingObjectException e) {-- throw new RevWalkException(e);-- } catch (IncorrectObjectTypeException e) {-- throw new RevWalkException(e);-- } catch (IOException e) {-- throw new RevWalkException(e);-- }++ RevCommit first = nextForIterator();return new Iterator<RevCommit>() {RevCommit next = first;@@@ -1374,17 -1374,17 +1382,9 @@@@Overridepublic RevCommit next() {-- try {-- final RevCommit r = next;-- next = RevWalk.this.next();-- return r;-- } catch (MissingObjectException e) {-- throw new RevWalkException(e);-- } catch (IncorrectObjectTypeException e) {-- throw new RevWalkException(e);-- } catch (IOException e) {-- throw new RevWalkException(e);-- }++ RevCommit r = next;++ next = nextForIterator();++ return r;}@Override