Skip to content
  • Michael Haggerty's avatar
    refs: store references hierarchically · 432ad41e
    Michael Haggerty authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Store references hierarchically in a tree that matches the
    pseudo-directory structure of the reference names.  Add a new kind of
    ref_entry (with flag REF_DIR) to represent a whole subdirectory of
    references.  Sort ref_dirs one subdirectory at a time.
    
    NOTE: the dirs can now be sorted as a side-effect of other function
    calls.  Therefore, it would be problematic to do something from a
    each_ref_fn callback that could provoke the sorting of a directory
    that is currently being iterated over (i.e., the directory containing
    the entry that is being processed or any of its parents).
    
    This is a bit far-fetched, because a directory is always sorted just
    before being iterated over.  Therefore, read-only accesses cannot
    trigger the sorting of a directory whose iteration has already
    started.  But if a callback function would add a reference to a parent
    directory of the reference in the iteration, then try to resolve a
    reference under that directory, a re-sort could be triggered and cause
    the iteration to work incorrectly.
    
    Nevertheless...add a comment in refs.h warning against modifications
    during iteration.
    
    Signed-off-by: default avatarMichael Haggerty <mhagger@alum.mit.edu>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    432ad41e