git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/6] reflog: introduce subcommand to list reflogs

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 19, 2024, 14:35 UTC
Message-ID
<cover.1708353264.git.ps@pks.im>
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
Next: Patrick Steinhardt
Message 1 of 39 in “reflog: introduce subcommand to list reflogs”
  1. 0/6 reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 19, 2024
  2. 1/6 dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt, Feb 19, 2024
  3. 2/6 dir-iterator: support iteration in sorted orderPatrick Steinhardt, Feb 19, 2024
  4. Junio C HamanoFeb 19, 2024
  5. Patrick SteinhardtFeb 20, 2024
  6. 3/6 refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt, Feb 19, 2024
  7. Junio C HamanoFeb 20, 2024
  8. Patrick SteinhardtFeb 20, 2024
  9. 4/6 refs: drop unused params from the reflog iterator callbackPatrick Steinhardt, Feb 19, 2024
  10. Junio C HamanoFeb 20, 2024
  11. Patrick SteinhardtFeb 20, 2024
  12. 5/6 refs: stop resolving ref corresponding to reflogsPatrick Steinhardt, Feb 19, 2024
  13. Junio C HamanoFeb 20, 2024
  14. Patrick SteinhardtFeb 20, 2024
  15. 6/6 builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 19, 2024
  16. Junio C HamanoFeb 20, 2024
  17. Patrick SteinhardtFeb 20, 2024
  18. 0/7 reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 20, 2024
  19. 1/7 dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt, Feb 20, 2024
  20. 2/7 dir-iterator: support iteration in sorted orderPatrick Steinhardt, Feb 20, 2024
  21. 3/7 refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt, Feb 20, 2024
  22. 4/7 refs: always treat iterators as orderedPatrick Steinhardt, Feb 20, 2024
  23. 5/7 refs: drop unused params from the reflog iterator callbackPatrick Steinhardt, Feb 20, 2024
  24. 6/7 refs: stop resolving ref corresponding to reflogsPatrick Steinhardt, Feb 20, 2024
  25. 7/7 builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 20, 2024
  26. 7/7 builtin/reflog: introduce subcommand to list reflogsTeng Long, Apr 24, 2024
  27. Patrick SteinhardtApr 24, 2024
  28. Junio C HamanoApr 24, 2024
  29. Junio C HamanoFeb 20, 2024
  30. Patrick SteinhardtFeb 21, 2024
  31. 0/8 reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 21, 2024
  32. 1/8 dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt, Feb 21, 2024
  33. 2/8 dir-iterator: support iteration in sorted orderPatrick Steinhardt, Feb 21, 2024
  34. 3/8 refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt, Feb 21, 2024
  35. 4/8 refs/files: sort merged worktree and common reflogsPatrick Steinhardt, Feb 21, 2024
  36. 5/8 refs: always treat iterators as orderedPatrick Steinhardt, Feb 21, 2024
  37. 6/8 refs: drop unused params from the reflog iterator callbackPatrick Steinhardt, Feb 21, 2024
  38. 7/8 refs: stop resolving ref corresponding to reflogsPatrick Steinhardt, Feb 21, 2024
  39. 8/8 builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 21, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.