diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-02-18 01:25:05 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-18 01:25:05 +0100 |
commit | 2f45f3e2bc859e5d5d29ede28de14f073c2dc227 (patch) | |
tree | 5ee746acec3fe482534dbb4c7c8b21c251b47115 /builtin/update-index.c | |
parent | Merge branch 'jz/rev-list-exclude-first-parent-only' (diff) | |
parent | update-index: reduce scope of index expansion in do_reupdate (diff) | |
download | git-2f45f3e2bc859e5d5d29ede28de14f073c2dc227.tar.xz git-2f45f3e2bc859e5d5d29ede28de14f073c2dc227.zip |
Merge branch 'vd/sparse-clean-etc'
"git update-index", "git checkout-index", and "git clean" are
taught to work better with the sparse checkout feature.
* vd/sparse-clean-etc:
update-index: reduce scope of index expansion in do_reupdate
update-index: integrate with sparse index
update-index: add tests for sparse-checkout compatibility
checkout-index: integrate with sparse index
checkout-index: add --ignore-skip-worktree-bits option
checkout-index: expand sparse checkout compatibility tests
clean: integrate with sparse index
reset: reorder wildcard pathspec conditions
reset: fix validation in sparse index test
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r-- | builtin/update-index.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c index 7e0a0d9bf8..aafe7eeac2 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -606,7 +606,7 @@ static struct cache_entry *read_one_ent(const char *which, error("%s: not in %s branch.", path, which); return NULL; } - if (mode == S_IFDIR) { + if (!the_index.sparse_index && mode == S_IFDIR) { if (which) error("%s: not a blob in %s branch.", path, which); return NULL; @@ -743,8 +743,6 @@ static int do_reupdate(int ac, const char **av, */ has_head = 0; redo: - /* TODO: audit for interaction with sparse-index. */ - ensure_full_index(&the_index); for (pos = 0; pos < active_nr; pos++) { const struct cache_entry *ce = active_cache[pos]; struct cache_entry *old = NULL; @@ -761,6 +759,16 @@ static int do_reupdate(int ac, const char **av, discard_cache_entry(old); continue; /* unchanged */ } + + /* At this point, we know the contents of the sparse directory are + * modified with respect to HEAD, so we expand the index and restart + * to process each path individually + */ + if (S_ISSPARSEDIR(ce->ce_mode)) { + ensure_full_index(&the_index); + goto redo; + } + /* Be careful. The working tree may not have the * path anymore, in which case, under 'allow_remove', * or worse yet 'allow_replace', active_nr may decrease. @@ -1088,6 +1096,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); + prepare_repo_settings(r); + the_repository->settings.command_requires_full_index = 0; + /* we will diagnose later if it turns out that we need to update it */ newfd = hold_locked_index(&lock_file, 0); if (newfd < 0) |