From: Junio C Hamano <gitster@pobox.com>
To: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Derrick Stolee <stolee@gmail.com>
Subject: Re: [PATCH] ls-files: conditionally leave index sparse
Date: Tue, 26 Aug 2025 12:00:18 -0700 [thread overview]
Message-ID: <xmqqh5xtkiwt.fsf@gitster.g> (raw)
In-Reply-To: <pull.1955.git.1755274373717.gitgitgadget@gmail.com> (Derrick Stolee via GitGitGadget's message of "Fri, 15 Aug 2025 16:12:53 +0000")
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 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.
> + */
In other words,
(1) we know that the original index entries are sorted
(2) we are looking at a single directory entry that is sparse, say
"D/", and ensure_full_index() will expand it (and other later
entries in the current index).
(3) we assume that the contents of "D/" will never sort before the
original location where "D/" used to sit, iow, we do not have
to rewind to the beginning of index->cache[] array and skip
what we have already processed.
Having bitten by the index sort order number of times, I just wanted
to make sure everybody's assumption is on the same page.
> + ensure_full_index(repo->index);
> + ce = repo->index->cache[i];
and there is no need to say "again" (redo this round of the loop)
here, as grabbing ce was the only thing the loop did, and we just
replaced the entry for the originally folded "D/" with one for the
first subpath in "D/". Sounds sensible.
prev parent reply other threads:[~2025-08-26 19:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 16:12 [PATCH] ls-files: conditionally leave index sparse Derrick Stolee via GitGitGadget
2025-08-26 16:40 ` Derrick Stolee
2025-08-27 19:36 ` Derrick Stolee
2025-08-28 15:02 ` Junio C Hamano
2025-08-26 18:37 ` Elijah Newren
2025-08-26 19:00 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqh5xtkiwt.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).