Skip to content
  • Patrick Steinhardt's avatar
    dir-iterator: support iteration in sorted order · de34f265
    Patrick Steinhardt authored and Junio C Hamano's avatar Junio C Hamano committed
    The `struct dir_iterator` is a helper that allows us to iterate through
    directory entries. This iterator returns entries in the exact same order
    as readdir(3P) does -- or in other words, it guarantees no specific
    order at all.
    
    This is about to become problematic as we are introducing a new reflog
    subcommand to list reflogs. As the "files" backend uses the directory
    iterator to enumerate reflogs, returning reflog names and exposing them
    to the user would inherit the indeterministic ordering. Naturally, it
    would make for a terrible user interface to show a list with no
    discernible order.
    
    While this could be handled at a higher level by the new subcommand
    itself by collecting and ordering the reflogs, this would be inefficient
    because we would first have to collect all reflogs before we can sort
    them, which would introduce additional latency when there are many
    reflogs.
    
    Instead, introduce a new option into the directory iterator that asks
    for its entries to ...
    de34f265