summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/commit.c3
-rw-r--r--read-cache.c10
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh13
3 files changed, 20 insertions, 6 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 190d215..12f51db 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1510,6 +1510,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(builtin_status_usage, builtin_status_options);
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
status_init_config(&s, git_status_config);
argc = parse_options(argc, argv, prefix,
builtin_status_options,
diff --git a/read-cache.c b/read-cache.c
index 77961a3..f67e049 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1585,8 +1585,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
*/
preload_index(istate, pathspec, 0);
trace2_region_enter("index", "refresh", NULL);
- /* TODO: audit for interaction with sparse-index. */
- ensure_full_index(istate);
+
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new_entry;
int cache_errno = 0;
@@ -1601,6 +1600,13 @@ int refresh_index(struct index_state *istate, unsigned int flags,
if (ignore_skip_worktree && ce_skip_worktree(ce))
continue;
+ /*
+ * If this entry is a sparse directory, then there isn't
+ * any stat() information to update. Ignore the entry.
+ */
+ if (S_ISSPARSEDIR(ce->ce_mode))
+ continue;
+
if (pathspec && !ce_path_match(istate, ce, pathspec, seen))
filtered = 1;
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 375b0d3..751f397 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -511,12 +511,17 @@ test_expect_success 'sparse-index is expanded and converted back' '
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
git -C sparse-index -c core.fsmonitor="" reset --hard &&
test_region index convert_to_sparse trace2.txt &&
- test_region index ensure_full_index trace2.txt &&
+ test_region index ensure_full_index trace2.txt
+'
- rm trace2.txt &&
+test_expect_success 'sparse-index is not expanded' '
+ init_repos &&
+
+ rm -f trace2.txt &&
+ echo >>sparse-index/untracked.txt &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
- git -C sparse-index -c core.fsmonitor="" status -uno &&
- test_region index ensure_full_index trace2.txt
+ git -C sparse-index status &&
+ test_region ! index ensure_full_index trace2.txt
'
test_done