Skip to content

Maintenance III: Background maintenance

Derrick Stolee via GitGitGadget git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7maintenance: optionally skip --auto processDocumentation/config/maintenance.txt run-command.c t/t7900-maintenance.sh+24 -00 replies
2/7maintenance: add --schedule option and configDocumentation/config/maintenance.txt Documentation/git-maintenance.txt builtin/gc.c +1 more+119 -62 replies
3/7for-each-repo: run subcommands on configured repos.gitignore Documentation/git-for-each-repo.txt Makefile +5 more+152 -00 replies
4/7maintenance: add [un]register subcommandsDocumentation/git-maintenance.txt builtin/gc.c t/t7900-maintenance.sh+84 -20 replies
5/7maintenance: add start/stop subcommandsDocumentation/git-maintenance.txt Makefile builtin/gc.c +5 more+207 -03 replies
6/7maintenance: recommended schedule in register/startDocumentation/git-maintenance.txt builtin/gc.c t/t7900-maintenance.sh+68 -00 replies
7/7maintenance: add troubleshooting guide to docsDocumentation/git-maintenance.txt+44 -00 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by.

PatchJunio C HamanoMartin Ågren
SeriesHelped-by Helped-by Helped-by Helped-by Helped-by Helped-by Helped-by
1/7
2/7
3/7
4/7
5/7
6/7
7/7Helped-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] Maintenance III: Background maintenance

This is based on ds/maintenance-part-2 and replaces the RFC from [1].

[1]
https://lore.kernel.org/git/[email protected]/

This series introduces background maintenance to Git, through an integration with cron and crontab.

Some preliminary work is done to allow a new --schedule option that tells the command which tasks to run based on a maintenance.<task>.schedule config option. The timing is not enforced by Git, but instead is expected to be provided as a hint from a cron schedule. The options are "hourly", "daily", and "weekly".

A new for-each-repo builtin runs Git commands on every repo in a given list. Currently, the list is stored as a config setting, allowing a new maintenance.repos config list to store the repositories registered for background maintenance. Others may want to add a --file=<file> option for their own workflows, but I focused on making this as simple as possible for now.

The updates to the git maintenance builtin include new register/unregister subcommands and start/stop subcommands. The register subcommand initializes the config while the start subcommand does everything register does plus update the cron table. The unregister and stop commands reverse this process.

A troubleshooting guide is added to Documentation/git-maintenance.txt to advise expert users who choose to create custom cron schedules.

The very last patch is entirely optional. It sets a recommended schedule based on my own experience with very large repositories. I'm open to other suggestions, but these are ones that I think work well and don't cause a "rewrite the world" scenario like running nightly 'gc' would do.

I've been testing this scenario on my macOS laptop and Linux desktop. I have modified my cron task to provide logging via trace2 so I can see what's happening. A future direction here would be to add some maintenance logs to the repository so we can track what is happening and diagnose whether the maintenance strategy is working on real repos.

Note: git maintenance (start|stop) only works on machines with cron by design. The proper thing to do on Windows will come later. Perhaps this command should be marked as unavailable on Windows somehow, or at least a better error than "cron may not be available on your system". I did find that that message is helpful sometimes: macOS worker agents for CI builds typically do not have cron available.

Derrick Stolee (7):
maintenance: optionally skip --auto process
maintenance: add --schedule option and config
for-each-repo: run subcommands on configured repos
maintenance: add [un]register subcommands
maintenance: add start/stop subcommands
maintenance: recommended schedule in register/start
maintenance: add troubleshooting guide to docs

 .gitignore                           |   1 +
 Documentation/config/maintenance.txt |  10 +
 Documentation/git-for-each-repo.txt  |  59 ++++++
 Documentation/git-maintenance.txt    |  88 +++++++-
 Makefile                             |   2 +
 builtin.h                            |   1 +
 builtin/for-each-repo.c              |  58 ++++++
 builtin/gc.c                         | 292 ++++++++++++++++++++++++++-
 command-list.txt                     |   1 +
 git.c                                |   1 +
 run-command.c                        |   6 +
 t/helper/test-crontab.c              |  35 ++++
 t/helper/test-tool.c                 |   1 +
 t/helper/test-tool.h                 |   1 +
 t/t0068-for-each-repo.sh             |  30 +++
 t/t7900-maintenance.sh               | 114 ++++++++++-
 t/test-lib.sh                        |   6 +
 17 files changed, 698 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/git-for-each-repo.txt
 create mode 100644 builtin/for-each-repo.c
 create mode 100644 t/helper/test-crontab.c
 create mode 100755 t/t0068-for-each-repo.sh

base-commit: e576ac2c7c7f6c7aa5ac08a516baeb61bf723596
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-724%2Fderrickstolee%2Fmaintenance%2Fscheduled-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-724/derrickstolee/maintenance/scheduled-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/724

Signature · 1 line
gitgitgadget