diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-04-30 04:50:26 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-04-30 04:50:26 (GMT) |
commit | 8e97852919fa422bc5fe57bc7e71826cf2b5224d (patch) | |
tree | 9a19699763f51c205f04fe05f67282c1cccde28b /unpack-trees.c | |
parent | d250f903596ee149dffcd65e3794dbd00b62f97e (diff) | |
parent | 4589bca829a2ace58bc98876cccd7dbd2e89f732 (diff) | |
download | git-8e97852919fa422bc5fe57bc7e71826cf2b5224d.zip git-8e97852919fa422bc5fe57bc7e71826cf2b5224d.tar.gz git-8e97852919fa422bc5fe57bc7e71826cf2b5224d.tar.bz2 |
Merge branch 'ds/sparse-index-protections'
Builds on top of the sparse-index infrastructure to mark operations
that are not ready to mark with the sparse index, causing them to
fall back on fully-populated index that they always have worked with.
* ds/sparse-index-protections: (47 commits)
name-hash: use expand_to_path()
sparse-index: expand_to_path()
name-hash: don't add directories to name_hash
revision: ensure full index
resolve-undo: ensure full index
read-cache: ensure full index
pathspec: ensure full index
merge-recursive: ensure full index
entry: ensure full index
dir: ensure full index
update-index: ensure full index
stash: ensure full index
rm: ensure full index
merge-index: ensure full index
ls-files: ensure full index
grep: ensure full index
fsck: ensure full index
difftool: ensure full index
commit: ensure full index
checkout: ensure full index
...
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index 8a1afbc..9cffa88 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -750,9 +750,13 @@ static int index_pos_by_traverse_info(struct name_entry *names, strbuf_make_traverse_path(&name, info, names->path, names->pathlen); strbuf_addch(&name, '/'); pos = index_name_pos(o->src_index, name.buf, name.len); - if (pos >= 0) - BUG("This is a directory and should not exist in index"); - pos = -pos - 1; + if (pos >= 0) { + if (!o->src_index->sparse_index || + !(o->src_index->cache[pos]->ce_flags & CE_SKIP_WORKTREE)) + BUG("This is a directory and should not exist in index"); + } else { + pos = -pos - 1; + } if (pos >= o->src_index->cache_nr || !starts_with(o->src_index->cache[pos]->name, name.buf) || (pos > 0 && starts_with(o->src_index->cache[pos-1]->name, name.buf))) @@ -1571,6 +1575,7 @@ static int verify_absent(const struct cache_entry *, */ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o) { + struct repository *repo = the_repository; int i, ret; static struct cache_entry *dfc; struct pattern_list pl; @@ -1582,6 +1587,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options trace_performance_enter(); trace2_region_enter("unpack_trees", "unpack_trees", the_repository); + prepare_repo_settings(repo); + if (repo->settings.command_requires_full_index) { + ensure_full_index(o->src_index); + ensure_full_index(o->dst_index); + } + if (!core_apply_sparse_checkout || !o->update) o->skip_sparse_checkout = 1; if (!o->skip_sparse_checkout && !o->pl) { |