Skip to content

Enumerating reflog entries in a wrong order

Junio C Hamano git 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3for_each_reflog_ent(): extract a helper to process a single entryrefs.c+30 -290 replies
2/3for_each_recent_reflog_ent(): simplify opening of a reflog filerefs.c+1 -30 replies
3/3reflog: add for_each_reflog_ent_reverse() APIrefs.c refs.h sha1_name.c+105 -470 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Enumerating reflog entries in a wrong order

The for_each_reflog_ent() function yields reflog entries from the oldest to newer, and is inefficient when we know what we are looking for are near the newest end (e.g. "find the nth newest reflog entry that matches 'checkout: moving from X to Y'"). To optimize for the common case, we introduced for_each_recent_reflog_ent() to scan only the newest part (i.e. tail) of the reflog file, but it is difficult to use this function correctly.

Just bite the bullet and stop working around the API that reads the file in a wrong order. The new for_each_reflog_ent_reverse() function gives us reflog entries from the newest to older.

Junio C Hamano (3):
for_each_reflog_ent(): extract a helper to process a single entry for_each_recent_reflog_ent(): simplify opening of a reflog file
reflog: add for_each_reflog_ent_reverse() API

 refs.c      | 161 +++++++++++++++++++++++++++++++++++++++++++-----------------
 refs.h      |   2 +-
 sha1_name.c |  48 +++++++-----------
 3 files changed, 134 insertions(+), 77 deletions(-)
Signature · 1 line
1.8.2-rc3-189-g94c4d42