Hi, this patch series introduces a new `git reflog list` subcommand that lists all reflogs of the current repository. This addresses an issue with discoverability as there is no way for a user to learn about which reflogs exist. While this isn't all that bad with the "files" backend as a user could in the worst case figure out which reflogs exist by walking the ".git/logs" directory, with the "reftable" backend it's basically impossible to achieve this. While I think this is sufficient motivation to have such a subcommand nowadays already, I think the need for such a thing will grow in the future. It was noted in multiple threads that we may eventually want to lift the artificial limitations in the "reftable" backend where reflogs are deleted together with their refs. This limitation is inherited from the "files" backend, which may otherwise hit issues with directory/file conflicts if it didn't delete reflogs. Once that limitation is lifted for the "reftable" backend though, it will become even more important to give users the tools to discover reflogs that do not have a corresponding ref. The series is structured as follows: - Patches 1-3 extend the dir iterator so that it can sort directory entries lexicographically. This is required such that we can list reflogs with deterministic ordering. - Patch 4 refactors the reflog iterator interface to demonstrate that the object ID and flags aren't needed nowadays, and patch 5 builds on top of that and stops resolving the refs altogether. This allows us to also surface reflogs of broken refs. - Patch 6 introduces the new subcommand. The series depends on Junio's ps/reftable-backend at 8a0bebdeae (refs/reftable: fix leak when copying reflog fails, 2024-02-08): the change in behaviour in patches 4 and 5 apply to both backends. Patrick Patrick Steinhardt (6): dir-iterator: pass name to `prepare_next_entry_data()` directly dir-iterator: support iteration in sorted order refs/files: sort reflogs returned by the reflog iterator refs: drop unused params from the reflog iterator callback refs: stop resolving ref corresponding to reflogs builtin/reflog: introduce subcommand to list reflogs Documentation/git-reflog.txt | 3 ++ builtin/fsck.c | 4 +- builtin/reflog.c | 37 +++++++++++++- dir-iterator.c | 93 ++++++++++++++++++++++++++-------- dir-iterator.h | 3 ++ refs.c | 23 +++++++-- refs.h | 11 +++- refs/files-backend.c | 22 ++------ refs/reftable-backend.c | 12 +---- revision.c | 4 +- t/helper/test-ref-store.c | 18 ++++--- t/t0600-reffiles-backend.sh | 24 ++++----- t/t1405-main-ref-store.sh | 8 +-- t/t1406-submodule-ref-store.sh | 8 +-- t/t1410-reflog.sh | 69 +++++++++++++++++++++++++ 15 files changed, 251 insertions(+), 88 deletions(-) -- 2.44.0-rc1
Attachment:
signature.asc
Description: PGP signature