• Show log

    Commit

  • Hash : 7aa03e92
    Author : Patrick Steinhardt
    Date : 2019-08-27T10:36:18

    diff_generate: refactor `DIFF_FROM_ITERATORS` macro of doom
    
    While the `DIFF_FROM_ITERATORS` does make it shorter to implement the
    various `git_diff_foo_to_bar` functions, it is a complex and unreadable
    beast that implicitly assumes certain local variable names. This is not
    something desirable to have at all and obstructs understanding and more
    importantly debugging the code by quite a bit.
    
    The `DIFF_FROM_ITERATORS` macro basically removed the burden of having
    to derive the options for both iterators from a pair of iterator flags
    and the diff options. This patch introduces a new function that does the
    that exact and refactors all callers to manage the iterators by
    themselves.
    
    As we potentially need to allocate a shared prefix for the
    iterator, we need to tell the caller to allocate that prefix as soon as
    the options aren't required anymore. Thus, the function has a `char
    **prefix` out pointer that will get set to the allocated string and
    subsequently be free'd by the caller.
    
    While this patch increases the line count, I personally deem this to an
    acceptable tradeoff for increased readbiblity.