From 3c1af2761f91ec7c17b648c0537e6c7f1847032e Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Thu, 11 Apr 2019 19:39:22 -0700 Subject: [PATCH] Process unshallow commits first DepthGenerator marks commits reinteresting for the ones that are reachable from unshallow commits as it walks over the revisions. Those unshallow commits won't necessarily be processed first. Because of this, even if a commit is reachable from unshallow commits, if it's processed before the uninteresting commits, it will not be processed as reinteresting and processed as uninteresting. This causes unshallow git-fetch to be failed. This changes DepthGenerator to process unshallow commits first independent to their depth. This makes uninteresting flag carry work properly. Change-Id: I94378271cf85fbe6302cefc19a167d8cf68e1a69 Signed-off-by: Masaya Suzuki --- .../org/eclipse/jgit/revwalk/DepthGenerator.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java index 515492039..5199a2927 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java @@ -108,12 +108,25 @@ class DepthGenerator extends Generator { // Begin by sucking out all of the source's commits, and // adding them to the pending queue + FIFORevQueue unshallowCommits = new FIFORevQueue(); for (;;) { RevCommit c = s.next(); if (c == null) break; - if (((DepthWalk.Commit) c).getDepth() == 0) + if (c.has(UNSHALLOW)) { + unshallowCommits.add(c); + } else if (((DepthWalk.Commit) c).getDepth() == 0) { pending.add(c); + } + } + // Move unshallow commits to the front so that the REINTERESTING flag + // carry over code is executed first. + for (;;) { + RevCommit c = unshallowCommits.next(); + if (c == null) { + break; + } + pending.unpop(c); } // Mark DEEPEN_NOT on all deepen-not commits and their ancestors.