[PATCH v4 07/12] unpack-trees: be careful around sparse directory entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Derrick Stolee <dstolee@xxxxxxxxxxxxx>

The methods traverse_by_cache_tree() and unpack_nondirectories() have
similar behavior in trying to demonstrate the difference between and
index and a tree, with some differences about how they walk the index.

Each of these is expecting every cache entry to correspond to a file
path. We need to skip over the sparse directory entries in the case of a
sparse-index. Those entries are discovered in the portion that looks for
subtrees among the cache entries by scanning the paths for slashes.

Skipping these sparse directory entries will have a measurable effect
when we relax 'git status' to work with sparse-indexes: without this
change these methods would call call_unpack_fn() which in turn calls
oneway_diff() and then shows these sparse directory entries as added or
modified files.

Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx>
---
 unpack-trees.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/unpack-trees.c b/unpack-trees.c
index ef6a2b1c951c..22634d98e72b 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -802,6 +802,9 @@ static int traverse_by_cache_tree(int pos, int nr_entries, int nr_names,
 
 		src[0] = o->src_index->cache[pos + i];
 
+		if (S_ISSPARSEDIR(src[0]->ce_mode))
+			continue;
+
 		len = ce_namelen(src[0]);
 		new_ce_len = cache_entry_size(len);
 
@@ -1074,6 +1077,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
 	if (mask == dirmask && !src[0])
 		return 0;
 
+	if (src[0] && S_ISSPARSEDIR(src[0]->ce_mode))
+		return 0;
+
 	/*
 	 * Ok, we've filled in up to any potential index entry in src[0],
 	 * now do the rest.
-- 
gitgitgadget




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux