Skip to content
  • Derrick Stolee's avatar
    maintenance: use pointers to check --auto · 916d0626
    Derrick Stolee authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    The 'git maintenance run' command has an '--auto' option. This is used
    by other Git commands such as 'git commit' or 'git fetch' to check if
    maintenance should be run after adding data to the repository.
    
    Previously, this --auto option was only used to add the argument to the
    'git gc' command as part of the 'gc' task. We will be expanding the
    other tasks to perform a check to see if they should do work as part of
    the --auto flag, when they are enabled by config.
    
    First, update the 'gc' task to perform the auto check inside the
    maintenance process. This prevents running an extra 'git gc --auto'
    command when not needed. It also shows a model for other tasks.
    
    Second, use the 'auto_condition' function pointer as a signal for
    whether we enable the maintenance task under '--auto'. For instance, we
    do not want to enable the 'fetch' task in '--auto' mode, so that
    function pointer will remain NULL.
    
    Now that we are not automatically calling 'git gc', a test in
    t5514-fetch-multiple.sh must be changed to watch for 'git maintenance'
    instead.
    
    We continue to pass the '--auto' option to the 'git gc' command when
    necessary, because of the gc.autoDetach config option changes behavior.
    Likely, we will want to absorb the daemonizing behavior implied by
    gc.autoDetach as a maintenance.autoDetach config option.
    
    Signed-off-by: default avatarDerrick Stolee <dstolee@microsoft.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    916d0626