diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-09-08 14:54:34 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-09-08 14:54:35 -0700 |
| commit | 576e0b6eb34f8989f07ae77db10baf1c75125c47 (patch) | |
| tree | c2962bfd758f54f9c54ca6c032080d19c7d9ce54 /builtin/ls-files.c | |
| parent | 4a7ebb9138b47bdc469fd8c8a97a753714fd5d92 (diff) | |
| parent | 681f26bccc017371ae6ee20db55e3edb52420a25 (diff) | |
| download | git-576e0b6eb34f8989f07ae77db10baf1c75125c47.tar.gz | |
Merge branch 'ds/ls-files-lazy-unsparse'
"git ls-files <pathspec>..." should not necessarily have to expand
the index fully if a sparsified directory is excluded by the
pathspec; the code is taught to expand the index on demand to avoid
this.
* ds/ls-files-lazy-unsparse:
ls-files: conditionally leave index sparse
Diffstat (limited to 'builtin/ls-files.c')
| -rw-r--r-- | builtin/ls-files.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c index c06a6f33e4..b148607f7a 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -414,14 +414,21 @@ static void show_files(struct repository *repo, struct dir_struct *dir) if (!(show_cached || show_stage || show_deleted || show_modified)) return; - if (!show_sparse_dirs) - ensure_full_index(repo->index); - for (i = 0; i < repo->index->cache_nr; i++) { const struct cache_entry *ce = repo->index->cache[i]; struct stat st; int stat_err; + if (S_ISSPARSEDIR(ce->ce_mode) && !show_sparse_dirs) { + /* + * This is the first time we've hit a sparse dir, + * so expansion will leave the first 'i' entries + * alone. + */ + ensure_full_index(repo->index); + ce = repo->index->cache[i]; + } + construct_fullname(&fullname, repo, ce); if ((dir->flags & DIR_SHOW_IGNORED) && |
