Skip to content
  • Adam Spiers's avatar
    dir.c: use a single struct exclude_list per source of excludes · c082df24
    Adam Spiers authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Previously each exclude_list could potentially contain patterns
    from multiple sources.  For example dir->exclude_list[EXC_FILE]
    would typically contain patterns from .git/info/exclude and
    core.excludesfile, and dir->exclude_list[EXC_DIRS] could contain
    patterns from multiple per-directory .gitignore files during
    directory traversal (i.e. when dir->exclude_stack was more than
    one item deep).
    
    We split these composite exclude_lists up into three groups of
    exclude_lists (EXC_CMDL / EXC_DIRS / EXC_FILE as before), so that each
    exclude_list now contains patterns from a single source.  This will
    allow us to cleanly track the origin of each pattern simply by adding
    a src field to struct exclude_list, rather than to struct exclude,
    which would make memory management of the source string tricky in the
    EXC_DIRS case where its contents are dynamically generated.
    
    Similarly, by moving the filebuf member from struct exclude_stack to
    struct exclude_list, it allows us to track and subsequently free
    memory buffers allocated during the parsing of all exclude files,
    rather than only tracking buffers allocated for files in the EXC_DIRS
    group.
    
    Signed-off-by: default avatarAdam Spiers <git@adamspiers.org>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    c082df24