Re: [PATCH 0/4] for-each-ref: introduce seeking functionality via '--skip-until'
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jul 2, 2025, 16:45 UTC
- Message-ID
- <CAOLa=ZRs44wc7gtyKqn+nkOtm306FNCGFWsm5=sgDBSFoB52LA@mail.gmail.com>
- In-Reply-To
- <xmqqfrffltym.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 28 quoted lines
> Karthik Nayak <karthik.188@gmail.com> 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. >
I totally didn't consider '--sort'. I do agree that we should document that behavior if we tend to keep it as is. I wonder if it is worthwhile to even prevent the two from being used together. I find the whole "we skip before sorting" to be very confusing.
Show 7 quoted lines
>> 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. >
Yup. We have 'sort_ref_dir()' to sort each directory parsed.
Show 5 quoted lines
>> 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.