Subject: Re: [PATCH 0/4] for-each-ref: introduce seeking functionality via '--skip-until'

From: Junio C Hamano <[email-masked]>
Date: Tue, 01 Jul 2025 10:08:33 -0700

Karthik Nayak <[email-masked]> writes:

> The `git-for-each-ref(1)` command is used to iterate over references
> present in a repository. In large repositories with millions of
> references, it would be optimal to paginate this output such that we
> can start iteration from a given reference.

I haven't looked at the patches, but should the end-user's mental
model of the process be like this?

 - We have a native order in which references are sorted and that is
   what "git for-each-ref" without "--sort" option gives them.

 - They can use the "--skip-until" option to seek in the above order
   and start iterating in the middle.

 - If they give "--sort", the set of refs to be shown would not
   change; skipping is done in the native order and then the
   remainder is given sorted.

Please make sure that the documentation is clear enough to avoid a
misunderstanding that this feature would kick in after we grab all
refs and sort them.  If it worked that way, it would allow us to say
"going from newer to older, but skipping the most recent ones that
were touched within a week", which would have been nice, but that is
not what we are doing with this feature---I think it is OK but we
need to be clear about it in the documentation.

> This series adds a '--skip-until' option in 'git-for-each-ref(1)'. When
> used, the reference iteration seeks to the first matching reference and
> iterates from there onward.

OK.  Even the filesystem backed ones we internall sort after doing
readdir() loop, so this is feasible.  Nice.

> Initally I was also planning to cleanup all the `refs_for_each...()`
> functions in 'refs.h' by simply using the iterator, but this bloated the
> series. So I've left that for another day.

OK.