• J
    refactor refs_from_alternate_cb to allow passing extra data · 114a6a88
    Jeff King 提交于
    The foreach_alt_odb function triggers a callback for each
    alternate object db we have, with room for a single void
    pointer as data. Currently, we always call refs_from_alternate_cb
    as the callback function, and then pass another callback (to
    receive each ref individually) as the void pointer.
    
    This has two problems:
    
      1. C technically forbids stuffing a function pointer into
         a "void *". In practice, this probably doesn't matter
         on any architectures git runs on, but it never hurts to
         follow the letter of the law.
    
      2. There is no room for an extra data pointer. Indeed, the
         alternate_ref_fn that refs_from_alternate_cb calls
         takes a void* for data, but we always pass it NULL.
    
    Instead, let's properly stuff our function pointer into a
    data struct, which also leaves room for an extra
    caller-supplied data pointer. And to keep things simple for
    existing callers, let's make a for_each_alternate_ref
    function that takes care of creating the extra struct.
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    114a6a88
receive-pack.c 20.0 KB