Skip to content
  • Ævar Arnfjörð Bjarmason's avatar
    gc: handle & check gc.reflogExpire config · bf3d70fe
    Ævar Arnfjörð Bjarmason authored and Junio C Hamano's avatar Junio C Hamano committed
    Don't redundantly run "git reflog expire --all" when gc.reflogExpire
    and gc.reflogExpireUnreachable are set to "never", and die immediately
    if those configuration valuer are bad.
    
    As an earlier "assert lack of early exit" change to the tests for "git
    reflog expire" shows, an early check of gc.reflogExpire{Unreachable,}
    isn't wanted in general for "git reflog expire", but it makes sense
    for "gc" because:
    
     1) Similarly to 8ab5aa4b
    
     ("parseopt: handle malformed --expire
        arguments more nicely", 2018-04-21) we'll now die early if the
        config variables are set to invalid values.
    
        We run "pack-refs" before "reflog expire", which can take a while,
        only to then die on an invalid gc.reflogExpire{Unreachable,}
        configuration.
    
     2) Not invoking the command at all means it won't show up in trace
        output, which makes what's going on more obvious when the two are
        set to "never".
    
     3) As a later change documents we lock the refs when looping over the
        refs to expire, even in cases where we end up doing nothing due to
        this config.
    
        For the reasons noted in the earlier "assert lack of early exit"
        change I don't think it's worth it to bend over backwards in "git
        reflog expire" itself to carefully detect if we'll really do
        nothing given the combination of all its possible options and skip
        that locking, but that's easy to detect here in "gc" where we'll
        only run "reflog expire" in a relatively simple mode.
    
    Signed-off-by: default avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    bf3d70fe