aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorHan-Wen NIenhuys <hanwen@google.com>2022-08-01 11:25:10 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2022-08-01 11:25:10 -0400
commit688c83d93ae0c230d22bb689b1c81184e002094c (patch)
treec34309017d68c911f4e11971530bc6ef0718a536 /org.eclipse.jgit/src
parent3bec0b56a556e6a513e990e8e84165ce6387ef53 (diff)
parent8584ac704849915cc573c98f277391d7c8b381a1 (diff)
downloadjgit-688c83d93ae0c230d22bb689b1c81184e002094c.tar.gz
jgit-688c83d93ae0c230d22bb689b1c81184e002094c.zip
Merge "NameConflictTreeWalk: respect git order on multi-tree iteration"
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/NameConflictTreeWalk.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/NameConflictTreeWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/NameConflictTreeWalk.java
index 28b7423817..3c8553c74f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/NameConflictTreeWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/NameConflictTreeWalk.java
@@ -268,6 +268,28 @@ public class NameConflictTreeWalk extends TreeWalk {
}
}
+ // When the combineDF is called, the t.matches field stores other
+ // entry (i.e. tree iterator) with an equal path. However, the
+ // previous loop moves each iterator independently. As a result,
+ // iterators which have had equals path at the start of the
+ // method can have different paths at this point.
+ // Reevaluate existing matches.
+ // The NameConflictTreeWalkTest.testDF_specialFileNames test
+ // cover this situation.
+ for (AbstractTreeIterator t : trees) {
+ // The previous loop doesn't touch tree iterator if it matches
+ // minRef. Skip it here
+ if (t.eof() || t.matches == null || t.matches == minRef)
+ continue;
+ // The t.pathCompare takes into account the entry type (file
+ // or directory) and returns non-zero value if names match
+ // but entry type don't match.
+ // We want to keep such matches (file/directory conflict),
+ // so reset matches only if names are not equal.
+ if (!nameEqual(t, t.matches))
+ t.matches = null;
+ }
+
if (treeMatch != null) {
// If we do have a conflict use one of the directory
// matching iterators instead of the file iterator.