--- v7
+++ v8
@@ -22,11 +22,11 @@
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
- unpack-trees.c | 105 +++++++++++++++++++++++++++++++++++++++++++++----
- 1 file changed, 97 insertions(+), 8 deletions(-)
+ unpack-trees.c | 107 +++++++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 99 insertions(+), 8 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
-index d26386ce8b2..d141dffbd94 100644
+index d26386ce8b2..62ccd5a0ff6 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1052,13 +1052,15 @@ static struct cache_entry *create_ce_entry(const struct traverse_info *info,
@@ -92,7 +92,7 @@
}
if (o->merge) {
-@@ -1222,16 +1240,69 @@ static int find_cache_pos(struct traverse_info *info,
+@@ -1222,16 +1240,71 @@ static int find_cache_pos(struct traverse_info *info,
return -1;
}
@@ -134,7 +134,7 @@
+ * Check for a sparse-directory entry named "path/".
+ * Due to the input p->path not having a trailing
+ * slash, the negative 'pos' value overshoots the
-+ * expected position by at least one, hence "-2" here.
++ * expected position, hence "-2" instead of "-1".
+ */
+ pos = -pos - 2;
+
@@ -142,9 +142,11 @@
return NULL;
+
+ /*
-+ * We might have multiple entries between 'pos' and
-+ * the actual sparse-directory entry, so start walking
-+ * back until finding it or passing where it would be.
++ * Due to lexicographic sorting and sparse directory
++ * entried ending with a trailing slash, our path as a
++ * sparse directory (e.g "subdir/") and our path as a
++ * file (e.g. "subdir") might be separated by other
++ * paths (e.g. "subdir-").
+ */
+ while (pos >= 0) {
+ ce = o->src_index->cache[pos];
@@ -163,7 +165,7 @@
}
static void debug_path(struct traverse_info *info)
-@@ -1266,6 +1337,21 @@ static void debug_unpack_callback(int n,
+@@ -1266,6 +1339,21 @@ static void debug_unpack_callback(int n,
debug_name_entry(i, names + i);
}
@@ -185,7 +187,7 @@
/*
* Note that traverse_by_cache_tree() duplicates some logic in this function
* without actually calling it. If you change the logic here you may need to
-@@ -1352,9 +1438,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
+@@ -1352,9 +1440,12 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
}
}