git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] for-each-ref: introduce seeking functionality via '--skip-until'
@ 2025-07-01 15:03 Karthik Nayak
  2025-07-01 15:03 ` [PATCH 1/4] refs: expose `ref_iterator` via 'refs.h' Karthik Nayak
                   ` (10 more replies)
  0 siblings, 11 replies; 102+ messages in thread
From: Karthik Nayak @ 2025-07-01 15:03 UTC (permalink / raw)
  To: git; +Cc: Karthik Nayak

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. This would avoid having to
iterate over all references from the beginning each time when paginating
through results.

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.

This enables efficient pagination workflows like:
    git for-each-ref --count=100
    git for-each-ref --count=100 --skip-until=refs/heads/branch-100
    git for-each-ref --count=100 --skip-until=refs/heads/branch-200

To add this functionality, we expose the `ref_iterator` outside the
'refs/' namespace and modify the `ref_iterator_seek()` to actually seek
to a given reference and only set the prefix when the `set_prefix` field
is set.

On the reftable and packed backend, the changes are simple. But since
the files backend uses 'ref-cache' for reference handling, the changes
there are a little more involved, since we need to setup the right
levels and the indexing.

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.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 Documentation/git-for-each-ref.adoc |   6 +-
 builtin/for-each-ref.c              |   5 +
 ref-filter.c                        |  57 ++++++++----
 ref-filter.h                        |   1 +
 refs.c                              |   2 +-
 refs.h                              | 153 ++++++++++++++++++++++++++++++
 refs/debug.c                        |   7 +-
 refs/files-backend.c                |   7 +-
 refs/iterator.c                     |  24 +++--
 refs/packed-backend.c               |  15 +--
 refs/ref-cache.c                    |  95 +++++++++++++++----
 refs/ref-cache.h                    |   7 --
 refs/refs-internal.h                | 152 ++----------------------------
 refs/reftable-backend.c             |  17 ++--
 t/t6302-for-each-ref-filter.sh      | 180 ++++++++++++++++++++++++++++++++++++
 15 files changed, 507 insertions(+), 221 deletions(-)

Karthik Nayak (4):
      refs: expose `ref_iterator` via 'refs.h'
      ref-cache: remove unused function 'find_ref_entry()'
      refs: selectively set prefix in the seek functions
      for-each-ref: introduce a '--skip-until' option



base-commit: cf6f63ea6bf35173e02e18bdc6a4ba41288acff9
change-id: 20250605-306-git-for-each-ref-pagination-0ba8a29ae646

Thanks
- Karthik


^ permalink raw reply	[flat|nested] 102+ messages in thread

end of thread, other threads:[~2025-07-24 22:30 UTC | newest]

Thread overview: 102+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01 15:03 [PATCH 0/4] for-each-ref: introduce seeking functionality via '--skip-until' Karthik Nayak
2025-07-01 15:03 ` [PATCH 1/4] refs: expose `ref_iterator` via 'refs.h' Karthik Nayak
2025-07-01 15:03 ` [PATCH 2/4] ref-cache: remove unused function 'find_ref_entry()' Karthik Nayak
2025-07-14 15:46   ` Junio C Hamano
2025-07-01 15:03 ` [PATCH 3/4] refs: selectively set prefix in the seek functions Karthik Nayak
2025-07-03  5:55   ` Patrick Steinhardt
2025-07-03  9:40     ` Karthik Nayak
2025-07-01 15:03 ` [PATCH 4/4] for-each-ref: introduce a '--skip-until' option Karthik Nayak
2025-07-03  5:55   ` Patrick Steinhardt
2025-07-03 10:02     ` Karthik Nayak
2025-07-03 10:59       ` Patrick Steinhardt
2025-07-01 17:08 ` [PATCH 0/4] for-each-ref: introduce seeking functionality via '--skip-until' Junio C Hamano
2025-07-02 16:45   ` Karthik Nayak
2025-07-01 21:37 ` Junio C Hamano
2025-07-02 18:19   ` Karthik Nayak
2025-07-03  8:41     ` Karthik Nayak
2025-07-02 14:14 ` Phillip Wood
2025-07-02 20:33   ` Karthik Nayak
2025-07-03  5:18     ` Patrick Steinhardt
2025-07-03  5:56       ` Junio C Hamano
2025-07-03  8:19         ` Patrick Steinhardt
2025-07-03  8:48           ` Karthik Nayak
2025-07-04 13:02 ` [PATCH v2 " Karthik Nayak
2025-07-04 13:02   ` [PATCH v2 1/4] refs: expose `ref_iterator` via 'refs.h' Karthik Nayak
2025-07-04 13:02   ` [PATCH v2 2/4] ref-cache: remove unused function 'find_ref_entry()' Karthik Nayak
2025-07-04 13:02   ` [PATCH v2 3/4] refs: selectively set prefix in the seek functions Karthik Nayak
2025-07-04 13:02   ` [PATCH v2 4/4] for-each-ref: introduce a '--skip-until' option Karthik Nayak
2025-07-07 15:30     ` Junio C Hamano
2025-07-07 18:31       ` Karthik Nayak
2025-07-04 13:41   ` [PATCH v2 0/4] for-each-ref: introduce seeking functionality via '--skip-until' Andreas Schwab
2025-07-04 14:02     ` Karthik Nayak
2025-07-04 14:52       ` Andreas Schwab
2025-07-04 14:58         ` Karthik Nayak
2025-07-04 15:55           ` Andreas Schwab
2025-07-07  8:52             ` Karthik Nayak
2025-07-04 16:39       ` Junio C Hamano
2025-07-07  8:59         ` Karthik Nayak
2025-07-07  9:45           ` Phillip Wood
2025-07-08 11:39             ` Karthik Nayak
2025-07-08 13:47 ` [PATCH v3 0/4] for-each-ref: introduce seeking functionality via '--start-after' Karthik Nayak
2025-07-08 13:47   ` [PATCH v3 1/4] refs: expose `ref_iterator` via 'refs.h' Karthik Nayak
2025-07-08 13:47   ` [PATCH v3 2/4] ref-cache: remove unused function 'find_ref_entry()' Karthik Nayak
2025-07-08 13:47   ` [PATCH v3 3/4] refs: selectively set prefix in the seek functions Karthik Nayak
2025-07-10  6:44     ` Patrick Steinhardt
2025-07-11  9:44       ` Karthik Nayak
2025-07-14 16:09       ` Junio C Hamano
2025-07-15  9:49         ` Karthik Nayak
2025-07-15 16:35           ` Junio C Hamano
2025-07-16 14:40             ` Karthik Nayak
2025-07-16 15:39               ` Junio C Hamano
2025-07-16 20:02               ` Junio C Hamano
2025-07-17  9:01                 ` Karthik Nayak
2025-07-17 17:31                   ` Junio C Hamano
2025-07-08 13:47   ` [PATCH v3 4/4] for-each-ref: introduce a '--start-after' option Karthik Nayak
2025-07-08 20:25     ` Junio C Hamano
2025-07-09  9:53       ` Karthik Nayak
2025-07-11 16:18 ` [PATCH v4 0/4] for-each-ref: introduce seeking functionality via '--start-after' Karthik Nayak
2025-07-11 16:18   ` [PATCH v4 1/4] refs: expose `ref_iterator` via 'refs.h' Karthik Nayak
2025-07-11 16:18   ` [PATCH v4 2/4] ref-cache: remove unused function 'find_ref_entry()' Karthik Nayak
2025-07-11 16:18   ` [PATCH v4 3/4] refs: selectively set prefix in the seek functions Karthik Nayak
2025-07-14 10:34     ` Christian Couder
2025-07-15  8:19       ` Karthik Nayak
2025-07-11 16:18   ` [PATCH v4 4/4] for-each-ref: introduce a '--start-after' option Karthik Nayak
2025-07-14 16:04     ` Christian Couder
2025-07-14 16:42       ` Junio C Hamano
2025-07-15  8:42       ` Karthik Nayak
2025-07-14 16:34   ` [PATCH v4 0/4] for-each-ref: introduce seeking functionality via '--start-after' Christian Couder
2025-07-14 16:49     ` Junio C Hamano
2025-07-15  9:49       ` Karthik Nayak
2025-07-15 11:28 ` [PATCH v5 0/5] " Karthik Nayak
2025-07-15 11:28   ` [PATCH v5 1/5] refs: expose `ref_iterator` via 'refs.h' Karthik Nayak
2025-07-15 11:28   ` [PATCH v5 2/5] ref-cache: remove unused function 'find_ref_entry()' Karthik Nayak
2025-07-17 14:48     ` Junio C Hamano
2025-07-17 19:31       ` Karthik Nayak
2025-07-17 20:32         ` Junio C Hamano
2025-07-15 11:28   ` [PATCH v5 3/5] refs: selectively set prefix in the seek functions Karthik Nayak
2025-07-17  2:09     ` Jeff King
2025-07-17 19:49       ` Karthik Nayak
2025-07-17 21:55         ` Jeff King
2025-07-15 11:28   ` [PATCH v5 4/5] ref-filter: remove unnecessary else clause Karthik Nayak
2025-07-15 11:28   ` [PATCH v5 5/5] for-each-ref: introduce a '--start-after' option Karthik Nayak
2025-07-17 15:31     ` Junio C Hamano
2025-07-22  8:07       ` Karthik Nayak
2025-07-15 19:00   ` [PATCH v5 0/5] for-each-ref: introduce seeking functionality via '--start-after' Junio C Hamano
2025-07-17  1:19     ` Kyle Lippincott
2025-07-17  1:54       ` Jeff King
2025-07-17 17:08         ` Kyle Lippincott
2025-07-17 19:26           ` Karthik Nayak
2025-07-17 19:35             ` Kyle Lippincott
2025-07-17 22:09               ` Jeff King
2025-07-17 22:16                 ` Jeff King
2025-07-21 14:27                 ` Karthik Nayak
2025-07-21 21:22                   ` Jeff King
2025-07-22  8:44                     ` Karthik Nayak
2025-07-17 22:21             ` Junio C Hamano
2025-07-23 21:51   ` [PATCH] ref-iterator-seek: correctly initialize the prefix_state for a new level Junio C Hamano
2025-07-23 21:57     ` Kyle Lippincott
2025-07-23 23:52     ` Jeff King
2025-07-24  8:12     ` Karthik Nayak
2025-07-24 17:01       ` Junio C Hamano
2025-07-24 22:11         ` [PATCH] ref-cache: set prefix_state when seeking Karthik Nayak
2025-07-24 22:30           ` Junio C Hamano

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).