Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
base: 76f5fdc2032d639c9a61ce7f49533a53884f05f6
Choose a base ref
...
head repository: git/git
compare: b681b191f923267aab80ae7f7ab2f85a692e8833
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Sep 7, 2021

  1. cache.h: Introduce a generic "xdg_config_home_for(…)" function

    Current implementation of `xdg_config_home(filename)` returns
    `$XDG_CONFIG_HOME/git/$filename`, with the `git` subdirectory inserted
    between the `XDG_CONFIG_HOME` environment variable and the parameter.
    
    This patch introduces a `xdg_config_home_for(subdir, filename)` function
    which is more generic. It only concatenates "$XDG_CONFIG_HOME", or
    "$HOME/.config" if the former isn’t defined, with the parameters,
    without adding `git` in between.
    
    `xdg_config_home(filename)` is now implemented by calling
    `xdg_config_home_for("git", filename)` but this new generic function can
    be used to compute the configuration directory of other programs.
    
    Signed-off-by: Lénaïc Huard <lenaic@lhuard.fr>
    Acked-by: Derrick Stolee <dstolee@microsoft.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    L3n41c authored and gitster committed Sep 7, 2021
    Copy the full SHA
    cb7db5b View commit details
    Browse the repository at this point in the history
  2. maintenance: git maintenance run learned --scheduler=<scheduler>

    Depending on the system, different schedulers can be used to schedule
    the hourly, daily and weekly executions of `git maintenance run`:
    * `launchctl` for MacOS,
    * `schtasks` for Windows and
    * `crontab` for everything else.
    
    `git maintenance run` now has an option to let the end-user explicitly
    choose which scheduler he wants to use:
    `--scheduler=auto|crontab|launchctl|schtasks`.
    
    When `git maintenance start --scheduler=XXX` is run, it not only
    registers `git maintenance run` tasks in the scheduler XXX, it also
    removes the `git maintenance run` tasks from all the other schedulers to
    ensure we cannot have two schedulers launching concurrent identical
    tasks.
    
    The default value is `auto` which chooses a suitable scheduler for the
    system.
    
    `git maintenance stop` doesn't have any `--scheduler` parameter because
    this command will try to remove the `git maintenance run` tasks from all
    the available schedulers.
    
    Signed-off-by: Lénaïc Huard <lenaic@lhuard.fr>
    Acked-by: Derrick Stolee <dstolee@microsoft.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    L3n41c authored and gitster committed Sep 7, 2021
    Copy the full SHA
    eba1ba9 View commit details
    Browse the repository at this point in the history
  3. maintenance: add support for systemd timers on Linux

    The existing mechanism for scheduling background maintenance is done
    through cron. On Linux systems managed by systemd, systemd provides an
    alternative to schedule recurring tasks: systemd timers.
    
    The main motivations to implement systemd timers in addition to cron
    are:
    * cron is optional and Linux systems running systemd might not have it
      installed.
    * The execution of `crontab -l` can tell us if cron is installed but not
      if the daemon is actually running.
    * With systemd, each service is run in its own cgroup and its logs are
      tagged by the service inside journald. With cron, all scheduled tasks
      are running in the cron daemon cgroup and all the logs of the
      user-scheduled tasks are pretended to belong to the system cron
      service.
      Concretely, a user that doesn’t have access to the system logs won’t
      have access to the log of their own tasks scheduled by cron whereas
      they will have access to the log of their own tasks scheduled by
      systemd timer.
      Although `cron` attempts to send email, that email may go unseen by
      the user because these days, local mailboxes are not heavily used
      anymore.
    
    In order to schedule git maintenance, we need two unit template files:
    * ~/.config/systemd/user/git-maintenance@.service
      to define the command to be started by systemd and
    * ~/.config/systemd/user/git-maintenance@.timer
      to define the schedule at which the command should be run.
    
    Those units are templates that are parameterized by the frequency.
    
    Based on those templates, 3 timers are started:
    * git-maintenance@hourly.timer
    * git-maintenance@daily.timer
    * git-maintenance@weekly.timer
    
    The command launched by those three timers are the same as with the
    other scheduling methods:
    
    /path/to/git for-each-repo --exec-path=/path/to
    --config=maintenance.repo maintenance run --schedule=%i
    
    with the full path for git to ensure that the version of git launched
    for the scheduled maintenance is the same as the one used to run
    `maintenance start`.
    
    The timer unit contains `Persistent=true` so that, if the computer is
    powered down when a maintenance task should run, the task will be run
    when the computer is back powered on.
    
    Signed-off-by: Lénaïc Huard <lenaic@lhuard.fr>
    Acked-by: Derrick Stolee <dstolee@microsoft.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    L3n41c authored and gitster committed Sep 7, 2021
    Copy the full SHA
    b681b19 View commit details
    Browse the repository at this point in the history