maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
git-maintenance(1)
|
|
|
|
==================
|
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
|
|
|
git-maintenance - Run tasks to optimize Git repository data
|
|
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
[verse]
|
|
|
|
'git maintenance' run [<options>]
|
|
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
Run tasks to optimize Git repository data, speeding up other Git commands
|
|
|
|
and reducing storage requirements for the repository.
|
|
|
|
|
|
|
|
Git commands that add repository data, such as `git add` or `git fetch`,
|
|
|
|
are optimized for a responsive user experience. These commands do not take
|
|
|
|
time to optimize the Git data, since such optimizations scale with the full
|
|
|
|
size of the repository while these user commands each perform a relatively
|
|
|
|
small action.
|
|
|
|
|
|
|
|
The `git maintenance` command provides flexibility for how to optimize the
|
|
|
|
Git repository.
|
|
|
|
|
|
|
|
SUBCOMMANDS
|
|
|
|
-----------
|
|
|
|
|
2020-09-11 17:49:17 +00:00
|
|
|
register::
|
|
|
|
Initialize Git config values so any scheduled maintenance will
|
|
|
|
start running on this repository. This adds the repository to the
|
|
|
|
`maintenance.repo` config variable in the current user's global
|
|
|
|
config and enables some recommended configuration values for
|
|
|
|
`maintenance.<task>.schedule`. The tasks that are enabled are safe
|
|
|
|
for running in the background without disrupting foreground
|
|
|
|
processes.
|
2020-10-15 17:22:03 +00:00
|
|
|
+
|
2021-01-03 14:25:50 +00:00
|
|
|
The `register` subcommand will also set the `maintenance.strategy` config
|
2020-10-15 17:22:03 +00:00
|
|
|
value to `incremental`, if this value is not previously set. The
|
|
|
|
`incremental` strategy uses the following schedule for each maintenance
|
|
|
|
task:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
* `gc`: disabled.
|
|
|
|
* `commit-graph`: hourly.
|
|
|
|
* `prefetch`: hourly.
|
|
|
|
* `loose-objects`: daily.
|
|
|
|
* `incremental-repack`: daily.
|
|
|
|
--
|
|
|
|
+
|
|
|
|
`git maintenance register` will also disable foreground maintenance by
|
|
|
|
setting `maintenance.auto = false` in the current repository. This config
|
|
|
|
setting will remain after a `git maintenance unregister` command.
|
2020-09-11 17:49:17 +00:00
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
run::
|
2020-09-17 18:11:49 +00:00
|
|
|
Run one or more maintenance tasks. If one or more `--task` options
|
|
|
|
are specified, then those tasks are run in that order. Otherwise,
|
|
|
|
the tasks are determined by which `maintenance.<task>.enabled`
|
|
|
|
config options are true. By default, only `maintenance.gc.enabled`
|
|
|
|
is true.
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
|
2020-09-11 17:49:18 +00:00
|
|
|
start::
|
|
|
|
Start running maintenance on the current repository. This performs
|
|
|
|
the same config updates as the `register` subcommand, then updates
|
|
|
|
the background scheduler to run `git maintenance run --scheduled`
|
|
|
|
on an hourly basis.
|
|
|
|
|
|
|
|
stop::
|
|
|
|
Halt the background maintenance schedule. The current repository
|
|
|
|
is not removed from the list of maintained repositories, in case
|
|
|
|
the background maintenance is restarted later.
|
|
|
|
|
2020-09-11 17:49:17 +00:00
|
|
|
unregister::
|
|
|
|
Remove the current repository from background maintenance. This
|
|
|
|
only removes the repository from the configured list. It does not
|
|
|
|
stop the background maintenance processes from running.
|
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
TASKS
|
|
|
|
-----
|
|
|
|
|
2020-09-17 18:11:46 +00:00
|
|
|
commit-graph::
|
|
|
|
The `commit-graph` job updates the `commit-graph` files incrementally,
|
|
|
|
then verifies that the written data is correct. The incremental
|
|
|
|
write is safe to run alongside concurrent Git processes since it
|
|
|
|
will not expire `.graph` files that were in the previous
|
|
|
|
`commit-graph-chain` file. They will be deleted by a later run based
|
|
|
|
on the expiration delay.
|
|
|
|
|
maintenance: add prefetch task
When working with very large repositories, an incremental 'git fetch'
command can download a large amount of data. If there are many other
users pushing to a common repo, then this data can rival the initial
pack-file size of a 'git clone' of a medium-size repo.
Users may want to keep the data on their local repos as close as
possible to the data on the remote repos by fetching periodically in
the background. This can break up a large daily fetch into several
smaller hourly fetches.
The task is called "prefetch" because it is work done in advance
of a foreground fetch to make that 'git fetch' command much faster.
However, if we simply ran 'git fetch <remote>' in the background,
then the user running a foreground 'git fetch <remote>' would lose
some important feedback when a new branch appears or an existing
branch updates. This is especially true if a remote branch is
force-updated and this isn't noticed by the user because it occurred
in the background. Further, the functionality of 'git push
--force-with-lease' becomes suspect.
When running 'git fetch <remote> <options>' in the background, use
the following options for careful updating:
1. --no-tags prevents getting a new tag when a user wants to see
the new tags appear in their foreground fetches.
2. --refmap= removes the configured refspec which usually updates
refs/remotes/<remote>/* with the refs advertised by the remote.
While this looks confusing, this was documented and tested by
b40a50264ac (fetch: document and test --refmap="", 2020-01-21),
including this sentence in the documentation:
Providing an empty `<refspec>` to the `--refmap` option
causes Git to ignore the configured refspecs and rely
entirely on the refspecs supplied as command-line arguments.
3. By adding a new refspec "+refs/heads/*:refs/prefetch/<remote>/*"
we can ensure that we actually load the new values somewhere in
our refspace while not updating refs/heads or refs/remotes. By
storing these refs here, the commit-graph job will update the
commit-graph with the commits from these hidden refs.
4. --prune will delete the refs/prefetch/<remote> refs that no
longer appear on the remote.
5. --no-write-fetch-head prevents updating FETCH_HEAD.
We've been using this step as a critical background job in Scalar
[1] (and VFS for Git). This solved a pain point that was showing up
in user reports: fetching was a pain! Users do not like waiting to
download the data that was created while they were away from their
machines. After implementing background fetch, the foreground fetch
commands sped up significantly because they mostly just update refs
and download a small amount of new data. The effect is especially
dramatic when paried with --no-show-forced-udpates (through
fetch.showForcedUpdates=false).
[1] https://github.com/microsoft/scalar/blob/master/Scalar.Common/Maintenance/FetchStep.cs
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-25 12:33:31 +00:00
|
|
|
prefetch::
|
|
|
|
The `prefetch` task updates the object directory with the latest
|
|
|
|
objects from all registered remotes. For each remote, a `git fetch`
|
2021-04-16 12:49:58 +00:00
|
|
|
command is run. The configured refspec is modified to place all
|
|
|
|
requested refs within `refs/prefetch/`. Also, tags are not updated.
|
maintenance: add prefetch task
When working with very large repositories, an incremental 'git fetch'
command can download a large amount of data. If there are many other
users pushing to a common repo, then this data can rival the initial
pack-file size of a 'git clone' of a medium-size repo.
Users may want to keep the data on their local repos as close as
possible to the data on the remote repos by fetching periodically in
the background. This can break up a large daily fetch into several
smaller hourly fetches.
The task is called "prefetch" because it is work done in advance
of a foreground fetch to make that 'git fetch' command much faster.
However, if we simply ran 'git fetch <remote>' in the background,
then the user running a foreground 'git fetch <remote>' would lose
some important feedback when a new branch appears or an existing
branch updates. This is especially true if a remote branch is
force-updated and this isn't noticed by the user because it occurred
in the background. Further, the functionality of 'git push
--force-with-lease' becomes suspect.
When running 'git fetch <remote> <options>' in the background, use
the following options for careful updating:
1. --no-tags prevents getting a new tag when a user wants to see
the new tags appear in their foreground fetches.
2. --refmap= removes the configured refspec which usually updates
refs/remotes/<remote>/* with the refs advertised by the remote.
While this looks confusing, this was documented and tested by
b40a50264ac (fetch: document and test --refmap="", 2020-01-21),
including this sentence in the documentation:
Providing an empty `<refspec>` to the `--refmap` option
causes Git to ignore the configured refspecs and rely
entirely on the refspecs supplied as command-line arguments.
3. By adding a new refspec "+refs/heads/*:refs/prefetch/<remote>/*"
we can ensure that we actually load the new values somewhere in
our refspace while not updating refs/heads or refs/remotes. By
storing these refs here, the commit-graph job will update the
commit-graph with the commits from these hidden refs.
4. --prune will delete the refs/prefetch/<remote> refs that no
longer appear on the remote.
5. --no-write-fetch-head prevents updating FETCH_HEAD.
We've been using this step as a critical background job in Scalar
[1] (and VFS for Git). This solved a pain point that was showing up
in user reports: fetching was a pain! Users do not like waiting to
download the data that was created while they were away from their
machines. After implementing background fetch, the foreground fetch
commands sped up significantly because they mostly just update refs
and download a small amount of new data. The effect is especially
dramatic when paried with --no-show-forced-udpates (through
fetch.showForcedUpdates=false).
[1] https://github.com/microsoft/scalar/blob/master/Scalar.Common/Maintenance/FetchStep.cs
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-25 12:33:31 +00:00
|
|
|
+
|
|
|
|
This is done to avoid disrupting the remote-tracking branches. The end users
|
|
|
|
expect these refs to stay unmoved unless they initiate a fetch. With prefetch
|
|
|
|
task, however, the objects necessary to complete a later real fetch would
|
|
|
|
already be obtained, so the real fetch would go faster. In the ideal case,
|
2020-12-21 21:26:31 +00:00
|
|
|
it will just become an update to a bunch of remote-tracking branches without
|
maintenance: add prefetch task
When working with very large repositories, an incremental 'git fetch'
command can download a large amount of data. If there are many other
users pushing to a common repo, then this data can rival the initial
pack-file size of a 'git clone' of a medium-size repo.
Users may want to keep the data on their local repos as close as
possible to the data on the remote repos by fetching periodically in
the background. This can break up a large daily fetch into several
smaller hourly fetches.
The task is called "prefetch" because it is work done in advance
of a foreground fetch to make that 'git fetch' command much faster.
However, if we simply ran 'git fetch <remote>' in the background,
then the user running a foreground 'git fetch <remote>' would lose
some important feedback when a new branch appears or an existing
branch updates. This is especially true if a remote branch is
force-updated and this isn't noticed by the user because it occurred
in the background. Further, the functionality of 'git push
--force-with-lease' becomes suspect.
When running 'git fetch <remote> <options>' in the background, use
the following options for careful updating:
1. --no-tags prevents getting a new tag when a user wants to see
the new tags appear in their foreground fetches.
2. --refmap= removes the configured refspec which usually updates
refs/remotes/<remote>/* with the refs advertised by the remote.
While this looks confusing, this was documented and tested by
b40a50264ac (fetch: document and test --refmap="", 2020-01-21),
including this sentence in the documentation:
Providing an empty `<refspec>` to the `--refmap` option
causes Git to ignore the configured refspecs and rely
entirely on the refspecs supplied as command-line arguments.
3. By adding a new refspec "+refs/heads/*:refs/prefetch/<remote>/*"
we can ensure that we actually load the new values somewhere in
our refspace while not updating refs/heads or refs/remotes. By
storing these refs here, the commit-graph job will update the
commit-graph with the commits from these hidden refs.
4. --prune will delete the refs/prefetch/<remote> refs that no
longer appear on the remote.
5. --no-write-fetch-head prevents updating FETCH_HEAD.
We've been using this step as a critical background job in Scalar
[1] (and VFS for Git). This solved a pain point that was showing up
in user reports: fetching was a pain! Users do not like waiting to
download the data that was created while they were away from their
machines. After implementing background fetch, the foreground fetch
commands sped up significantly because they mostly just update refs
and download a small amount of new data. The effect is especially
dramatic when paried with --no-show-forced-udpates (through
fetch.showForcedUpdates=false).
[1] https://github.com/microsoft/scalar/blob/master/Scalar.Common/Maintenance/FetchStep.cs
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-25 12:33:31 +00:00
|
|
|
any object transfer.
|
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
gc::
|
|
|
|
Clean up unnecessary files and optimize the local repository. "GC"
|
|
|
|
stands for "garbage collection," but this task performs many
|
|
|
|
smaller tasks. This task can be expensive for large repositories,
|
|
|
|
as it repacks all Git objects into a single pack-file. It can also
|
|
|
|
be disruptive in some situations, as it deletes stale data. See
|
|
|
|
linkgit:git-gc[1] for more details on garbage collection in Git.
|
|
|
|
|
2020-09-25 12:33:32 +00:00
|
|
|
loose-objects::
|
|
|
|
The `loose-objects` job cleans up loose objects and places them into
|
|
|
|
pack-files. In order to prevent race conditions with concurrent Git
|
|
|
|
commands, it follows a two-step process. First, it deletes any loose
|
|
|
|
objects that already exist in a pack-file; concurrent Git processes
|
|
|
|
will examine the pack-file for the object data instead of the loose
|
|
|
|
object. Second, it creates a new pack-file (starting with "loose-")
|
|
|
|
containing a batch of loose objects. The batch size is limited to 50
|
|
|
|
thousand objects to prevent the job from taking too long on a
|
|
|
|
repository with many loose objects. The `gc` task writes unreachable
|
|
|
|
objects as loose objects to be cleaned up by a later step only if
|
|
|
|
they are not re-added to a pack-file; for this reason it is not
|
|
|
|
advisable to enable both the `loose-objects` and `gc` tasks at the
|
|
|
|
same time.
|
|
|
|
|
maintenance: add incremental-repack task
The previous change cleaned up loose objects using the
'loose-objects' that can be run safely in the background. Add a
similar job that performs similar cleanups for pack-files.
One issue with running 'git repack' is that it is designed to
repack all pack-files into a single pack-file. While this is the
most space-efficient way to store object data, it is not time or
memory efficient. This becomes extremely important if the repo is
so large that a user struggles to store two copies of the pack on
their disk.
Instead, perform an "incremental" repack by collecting a few small
pack-files into a new pack-file. The multi-pack-index facilitates
this process ever since 'git multi-pack-index expire' was added in
19575c7 (multi-pack-index: implement 'expire' subcommand,
2019-06-10) and 'git multi-pack-index repack' was added in ce1e4a1
(midx: implement midx_repack(), 2019-06-10).
The 'incremental-repack' task runs the following steps:
1. 'git multi-pack-index write' creates a multi-pack-index file if
one did not exist, and otherwise will update the multi-pack-index
with any new pack-files that appeared since the last write. This
is particularly relevant with the background fetch job.
When the multi-pack-index sees two copies of the same object, it
stores the offset data into the newer pack-file. This means that
some old pack-files could become "unreferenced" which I will use
to mean "a pack-file that is in the pack-file list of the
multi-pack-index but none of the objects in the multi-pack-index
reference a location inside that pack-file."
2. 'git multi-pack-index expire' deletes any unreferenced pack-files
and updaes the multi-pack-index to drop those pack-files from the
list. This is safe to do as concurrent Git processes will see the
multi-pack-index and not open those packs when looking for object
contents. (Similar to the 'loose-objects' job, there are some Git
commands that open pack-files regardless of the multi-pack-index,
but they are rarely used. Further, a user that self-selects to
use background operations would likely refrain from using those
commands.)
3. 'git multi-pack-index repack --bacth-size=<size>' collects a set
of pack-files that are listed in the multi-pack-index and creates
a new pack-file containing the objects whose offsets are listed
by the multi-pack-index to be in those objects. The set of pack-
files is selected greedily by sorting the pack-files by modified
time and adding a pack-file to the set if its "expected size" is
smaller than the batch size until the total expected size of the
selected pack-files is at least the batch size. The "expected
size" is calculated by taking the size of the pack-file divided
by the number of objects in the pack-file and multiplied by the
number of objects from the multi-pack-index with offset in that
pack-file. The expected size approximates how much data from that
pack-file will contribute to the resulting pack-file size. The
intention is that the resulting pack-file will be close in size
to the provided batch size.
The next run of the incremental-repack task will delete these
repacked pack-files during the 'expire' step.
In this version, the batch size is set to "0" which ignores the
size restrictions when selecting the pack-files. It instead
selects all pack-files and repacks all packed objects into a
single pack-file. This will be updated in the next change, but
it requires doing some calculations that are better isolated to
a separate change.
These steps are based on a similar background maintenance step in
Scalar (and VFS for Git) [1]. This was incredibly effective for
users of the Windows OS repository. After using the same VFS for Git
repository for over a year, some users had _thousands_ of pack-files
that combined to up to 250 GB of data. We noticed a few users were
running into the open file descriptor limits (due in part to a bug
in the multi-pack-index fixed by af96fe3 (midx: add packs to
packed_git linked list, 2019-04-29).
These pack-files were mostly small since they contained the commits
and trees that were pushed to the origin in a given hour. The GVFS
protocol includes a "prefetch" step that asks for pre-computed pack-
files containing commits and trees by timestamp. These pack-files
were grouped into "daily" pack-files once a day for up to 30 days.
If a user did not request prefetch packs for over 30 days, then they
would get the entire history of commits and trees in a new, large
pack-file. This led to a large number of pack-files that had poor
delta compression.
By running this pack-file maintenance step once per day, these repos
with thousands of packs spanning 200+ GB dropped to dozens of pack-
files spanning 30-50 GB. This was done all without removing objects
from the system and using a constant batch size of two gigabytes.
Once the work was done to reduce the pack-files to small sizes, the
batch size of two gigabytes means that not every run triggers a
repack operation, so the following run will not expire a pack-file.
This has kept these repos in a "clean" state.
[1] https://github.com/microsoft/scalar/blob/master/Scalar.Common/Maintenance/PackfileMaintenanceStep.cs
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-25 12:33:36 +00:00
|
|
|
incremental-repack::
|
|
|
|
The `incremental-repack` job repacks the object directory
|
|
|
|
using the `multi-pack-index` feature. In order to prevent race
|
|
|
|
conditions with concurrent Git commands, it follows a two-step
|
|
|
|
process. First, it calls `git multi-pack-index expire` to delete
|
|
|
|
pack-files unreferenced by the `multi-pack-index` file. Second, it
|
|
|
|
calls `git multi-pack-index repack` to select several small
|
|
|
|
pack-files and repack them into a bigger one, and then update the
|
|
|
|
`multi-pack-index` entries that refer to the small pack-files to
|
|
|
|
refer to the new pack-file. This prepares those small pack-files
|
|
|
|
for deletion upon the next run of `git multi-pack-index expire`.
|
|
|
|
The selection of the small pack-files is such that the expected
|
|
|
|
size of the big pack-file is at least the batch size; see the
|
|
|
|
`--batch-size` option for the `repack` subcommand in
|
|
|
|
linkgit:git-multi-pack-index[1]. The default batch-size is zero,
|
|
|
|
which is a special case that attempts to repack all pack-files
|
|
|
|
into a single pack-file.
|
|
|
|
|
2021-02-09 13:42:28 +00:00
|
|
|
pack-refs::
|
|
|
|
The `pack-refs` task collects the loose reference files and
|
|
|
|
collects them into a single file. This speeds up operations that
|
|
|
|
need to iterate across many references. See linkgit:git-pack-refs[1]
|
|
|
|
for more information.
|
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
OPTIONS
|
|
|
|
-------
|
|
|
|
--auto::
|
|
|
|
When combined with the `run` subcommand, run maintenance tasks
|
|
|
|
only if certain thresholds are met. For example, the `gc` task
|
|
|
|
runs when the number of loose objects exceeds the number stored
|
|
|
|
in the `gc.auto` config setting, or when the number of pack-files
|
2020-09-11 17:49:15 +00:00
|
|
|
exceeds the `gc.autoPackLimit` config setting. Not compatible with
|
|
|
|
the `--schedule` option.
|
|
|
|
|
|
|
|
--schedule::
|
|
|
|
When combined with the `run` subcommand, run maintenance tasks
|
|
|
|
only if certain time conditions are met, as specified by the
|
|
|
|
`maintenance.<task>.schedule` config value for each `<task>`.
|
|
|
|
This config value specifies a number of seconds since the last
|
|
|
|
time that task ran, according to the `maintenance.<task>.lastRun`
|
|
|
|
config value. The tasks that are tested are those provided by
|
|
|
|
the `--task=<task>` option(s) or those with
|
|
|
|
`maintenance.<task>.enabled` set to true.
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
|
2020-09-17 18:11:43 +00:00
|
|
|
--quiet::
|
|
|
|
Do not report progress or other information over `stderr`.
|
|
|
|
|
2020-09-17 18:11:47 +00:00
|
|
|
--task=<task>::
|
|
|
|
If this option is specified one or more times, then only run the
|
2020-09-17 18:11:49 +00:00
|
|
|
specified tasks in the specified order. If no `--task=<task>`
|
|
|
|
arguments are specified, then only the tasks with
|
|
|
|
`maintenance.<task>.enabled` configured as `true` are considered.
|
|
|
|
See the 'TASKS' section for the list of accepted `<task>` values.
|
2020-09-17 18:11:47 +00:00
|
|
|
|
2020-10-15 17:22:04 +00:00
|
|
|
|
|
|
|
TROUBLESHOOTING
|
|
|
|
---------------
|
|
|
|
The `git maintenance` command is designed to simplify the repository
|
|
|
|
maintenance patterns while minimizing user wait time during Git commands.
|
|
|
|
A variety of configuration options are available to allow customizing this
|
|
|
|
process. The default maintenance options focus on operations that complete
|
|
|
|
quickly, even on large repositories.
|
|
|
|
|
|
|
|
Users may find some cases where scheduled maintenance tasks do not run as
|
|
|
|
frequently as intended. Each `git maintenance run` command takes a lock on
|
|
|
|
the repository's object database, and this prevents other concurrent
|
|
|
|
`git maintenance run` commands from running on the same repository. Without
|
|
|
|
this safeguard, competing processes could leave the repository in an
|
|
|
|
unpredictable state.
|
|
|
|
|
|
|
|
The background maintenance schedule runs `git maintenance run` processes
|
|
|
|
on an hourly basis. Each run executes the "hourly" tasks. At midnight,
|
|
|
|
that process also executes the "daily" tasks. At midnight on the first day
|
|
|
|
of the week, that process also executes the "weekly" tasks. A single
|
|
|
|
process iterates over each registered repository, performing the scheduled
|
|
|
|
tasks for that frequency. Depending on the number of registered
|
|
|
|
repositories and their sizes, this process may take longer than an hour.
|
|
|
|
In this case, multiple `git maintenance run` commands may run on the same
|
|
|
|
repository at the same time, colliding on the object database lock. This
|
|
|
|
results in one of the two tasks not running.
|
|
|
|
|
|
|
|
If you find that some maintenance windows are taking longer than one hour
|
|
|
|
to complete, then consider reducing the complexity of your maintenance
|
|
|
|
tasks. For example, the `gc` task is much slower than the
|
|
|
|
`incremental-repack` task. However, this comes at a cost of a slightly
|
|
|
|
larger object database. Consider moving more expensive tasks to be run
|
|
|
|
less frequently.
|
|
|
|
|
|
|
|
Expert users may consider scheduling their own maintenance tasks using a
|
|
|
|
different schedule than is available through `git maintenance start` and
|
|
|
|
Git configuration options. These users should be aware of the object
|
|
|
|
database lock and how concurrent `git maintenance run` commands behave.
|
|
|
|
Further, the `git gc` command should not be combined with
|
|
|
|
`git maintenance run` commands. `git gc` modifies the object database
|
|
|
|
but does not take the lock in the same way as `git maintenance run`. If
|
|
|
|
possible, use `git maintenance run --task=gc` instead of `git gc`.
|
|
|
|
|
2020-11-24 04:16:43 +00:00
|
|
|
The following sections describe the mechanisms put in place to run
|
|
|
|
background maintenance by `git maintenance start` and how to customize
|
|
|
|
them.
|
|
|
|
|
|
|
|
BACKGROUND MAINTENANCE ON POSIX SYSTEMS
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
The standard mechanism for scheduling background tasks on POSIX systems
|
|
|
|
is cron(8). This tool executes commands based on a given schedule. The
|
|
|
|
current list of user-scheduled tasks can be found by running `crontab -l`.
|
|
|
|
The schedule written by `git maintenance start` is similar to this:
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
# BEGIN GIT MAINTENANCE SCHEDULE
|
|
|
|
# The following schedule was created by Git
|
|
|
|
# Any edits made in this region might be
|
|
|
|
# replaced in the future by a Git command.
|
|
|
|
|
|
|
|
0 1-23 * * * "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly
|
|
|
|
0 0 * * 1-6 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=daily
|
|
|
|
0 0 * * 0 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly
|
|
|
|
|
|
|
|
# END GIT MAINTENANCE SCHEDULE
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
The comments are used as a region to mark the schedule as written by Git.
|
|
|
|
Any modifications within this region will be completely deleted by
|
|
|
|
`git maintenance stop` or overwritten by `git maintenance start`.
|
|
|
|
|
|
|
|
The `crontab` entry specifies the full path of the `git` executable to
|
|
|
|
ensure that the executed `git` command is the same one with which
|
|
|
|
`git maintenance start` was issued independent of `PATH`. If the same user
|
|
|
|
runs `git maintenance start` with multiple Git executables, then only the
|
|
|
|
latest executable is used.
|
|
|
|
|
|
|
|
These commands use `git for-each-repo --config=maintenance.repo` to run
|
|
|
|
`git maintenance run --schedule=<frequency>` on each repository listed in
|
|
|
|
the multi-valued `maintenance.repo` config option. These are typically
|
|
|
|
loaded from the user-specific global config. The `git maintenance` process
|
|
|
|
then determines which maintenance tasks are configured to run on each
|
|
|
|
repository with each `<frequency>` using the `maintenance.<task>.schedule`
|
|
|
|
config options. These values are loaded from the global or repository
|
|
|
|
config values.
|
|
|
|
|
|
|
|
If the config values are insufficient to achieve your desired background
|
|
|
|
maintenance schedule, then you can create your own schedule. If you run
|
|
|
|
`crontab -e`, then an editor will load with your user-specific `cron`
|
|
|
|
schedule. In that editor, you can add your own schedule lines. You could
|
|
|
|
start by adapting the default schedule listed earlier, or you could read
|
|
|
|
the crontab(5) documentation for advanced scheduling techniques. Please
|
|
|
|
do use the full path and `--exec-path` techniques from the default
|
|
|
|
schedule to ensure you are executing the correct binaries in your
|
|
|
|
schedule.
|
|
|
|
|
2020-10-15 17:22:04 +00:00
|
|
|
|
maintenance: use launchctl on macOS
The existing mechanism for scheduling background maintenance is done
through cron. The 'crontab -e' command allows updating the schedule
while cron itself runs those commands. While this is technically
supported by macOS, it has some significant deficiencies:
1. Every run of 'crontab -e' must request elevated privileges through
the user interface. When running 'git maintenance start' from the
Terminal app, it presents a dialog box saying "Terminal.app would
like to administer your computer. Administration can include
modifying passwords, networking, and system settings." This is more
alarming than what we are hoping to achieve. If this alert had some
information about how "git" is trying to run "crontab" then we would
have some reason to believe that this dialog might be fine. However,
it also doesn't help that some scenarios just leave Git waiting for
a response without presenting anything to the user. I experienced
this when executing the command from a Bash terminal view inside
Visual Studio Code.
2. While cron initializes a user environment enough for "git config
--global --show-origin" to show the correct config file information,
it does not set up the environment enough for Git Credential Manager
Core to load credentials during a 'prefetch' task. My prefetches
against private repositories required re-authenticating through UI
pop-ups in a way that should not be required.
The solution is to switch from cron to the Apple-recommended [1]
'launchd' tool.
[1] https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html
The basics of this tool is that we need to create XML-formatted
"plist" files inside "~/Library/LaunchAgents/" and then use the
'launchctl' tool to make launchd aware of them. The plist files
include all of the scheduling information, along with the command-line
arguments split across an array of <string> tags.
For example, here is my plist file for the weekly scheduled tasks:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>org.git-scm.git.weekly</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/libexec/git-core/git</string>
<string>--exec-path=/usr/local/libexec/git-core</string>
<string>for-each-repo</string>
<string>--config=maintenance.repo</string>
<string>maintenance</string>
<string>run</string>
<string>--schedule=weekly</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Day</key><integer>0</integer>
<key>Hour</key><integer>0</integer>
<key>Minute</key><integer>0</integer>
</dict>
</array>
</dict>
</plist>
The schedules for the daily and hourly tasks are more complicated
since we need to use an array for the StartCalendarInterval with
an entry for each of the six days other than the 0th day (to avoid
colliding with the weekly task), and each of the 23 hours other
than the 0th hour (to avoid colliding with the daily task).
The "Label" value is currently filled with "org.git-scm.git.X"
where X is the frequency. We need a different plist file for each
frequency.
The launchctl command needs to be aligned with a user id in order
to initialize the command environment. This must be done using
the 'launchctl bootstrap' subcommand. This subcommand is new as
of macOS 10.11, which was released in September 2015. Before that
release the 'launchctl load' subcommand was recommended. The best
source of information on this transition I have seen is available
at [2]. The current design does not preclude a future version that
detects the available fatures of 'launchctl' to use the older
commands. However, it is best to rely on the newest version since
Apple might completely remove the deprecated version on short
notice.
[2] https://babodee.wordpress.com/2016/04/09/launchctl-2-0-syntax/
To remove a schedule, we must run 'launchctl bootout' with a valid
plist file. We also need to 'bootout' a task before the 'bootstrap'
subcommand will succeed, if such a task already exists.
The need for a user id requires us to run 'id -u' which works on
POSIX systems but not Windows. Further, the need for fully-qualitifed
path names including $HOME behaves differently in the Git internals and
the external test suite. The $HOME variable starts with "C:\..." instead
of the "/c/..." that is provided by Git in these subcommands. The test
therefore has a prerequisite that we are not on Windows. The cross-
platform logic still allows us to test the macOS logic on a Linux
machine.
We can verify the commands that were run by 'git maintenance start'
and 'git maintenance stop' by injecting a script that writes the
command-line arguments into GIT_TEST_MAINT_SCHEDULER.
An earlier version of this patch accidentally had an opening
"<dict>" tag when it should have had a closing "</dict>" tag. This
was caught during manual testing with actual 'launchctl' commands,
but we do not want to update developers' tasks when running tests.
It appears that macOS includes the "xmllint" tool which can verify
the XML format. This is useful for any system that might contain
the tool, so use it whenever it is available.
We strive to make these tests work on all platforms, but Windows caused
some headaches. In particular, the value of getuid() called by the C
code is not guaranteed to be the same as `$(id -u)` invoked by a test.
This is because `git.exe` is a native Windows program, whereas the
utility programs run by the test script mostly utilize the MSYS2 runtime,
which emulates a POSIX-like environment. Since the purpose of the test
is to check that the input to the hook is well-formed, the actual user
ID is immaterial, thus we can work around the problem by making the the
test UID-agnostic. Another subtle issue is the $HOME environment
variable being a Windows-style path instead of a Unix-style path. We can
be more flexible here instead of expecting exact path matches.
Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Co-authored-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 13:08:27 +00:00
|
|
|
BACKGROUND MAINTENANCE ON MACOS SYSTEMS
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
While macOS technically supports `cron`, using `crontab -e` requires
|
|
|
|
elevated privileges and the executed process does not have a full user
|
|
|
|
context. Without a full user context, Git and its credential helpers
|
|
|
|
cannot access stored credentials, so some maintenance tasks are not
|
|
|
|
functional.
|
|
|
|
|
|
|
|
Instead, `git maintenance start` interacts with the `launchctl` tool,
|
|
|
|
which is the recommended way to schedule timed jobs in macOS. Scheduling
|
|
|
|
maintenance through `git maintenance (start|stop)` requires some
|
|
|
|
`launchctl` features available only in macOS 10.11 or later.
|
|
|
|
|
|
|
|
Your user-specific scheduled tasks are stored as XML-formatted `.plist`
|
|
|
|
files in `~/Library/LaunchAgents/`. You can see the currently-registered
|
|
|
|
tasks using the following command:
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
$ ls ~/Library/LaunchAgents/org.git-scm.git*
|
|
|
|
org.git-scm.git.daily.plist
|
|
|
|
org.git-scm.git.hourly.plist
|
|
|
|
org.git-scm.git.weekly.plist
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
One task is registered for each `--schedule=<frequency>` option. To
|
|
|
|
inspect how the XML format describes each schedule, open one of these
|
|
|
|
`.plist` files in an editor and inspect the `<array>` element following
|
|
|
|
the `<key>StartCalendarInterval</key>` element.
|
|
|
|
|
|
|
|
`git maintenance start` will overwrite these files and register the
|
|
|
|
tasks again with `launchctl`, so any customizations should be done by
|
|
|
|
creating your own `.plist` files with distinct names. Similarly, the
|
|
|
|
`git maintenance stop` command will unregister the tasks with `launchctl`
|
|
|
|
and delete the `.plist` files.
|
|
|
|
|
|
|
|
To create more advanced customizations to your background tasks, see
|
|
|
|
launchctl.plist(5) for more information.
|
|
|
|
|
|
|
|
|
maintenance: use Windows scheduled tasks
Git's background maintenance uses cron by default, but this is not
available on Windows. Instead, integrate with Task Scheduler.
Tasks can be scheduled using the 'schtasks' command. There are several
command-line options that can allow for some advanced scheduling, but
unfortunately these seem to all require authenticating using a password.
Instead, use the "/xml" option to pass an XML file that contains the
configuration for the necessary schedule. These XML files are based on
some that I exported after constructing a schedule in the Task Scheduler
GUI. These options only run background maintenance when the user is
logged in, and more fields are populated with the current username and
SID at run-time by 'schtasks'.
Since the GIT_TEST_MAINT_SCHEDULER environment variable allows us to
specify 'schtasks' as the scheduler, we can test the Windows-specific
logic on other platforms. Thus, add a check that the XML file written
by Git is valid when xmllint exists on the system.
Since we use a temporary file for the XML files sent to 'schtasks', we
prefix the random characters with the frequency so it is easier to
examine the proper file during tests. Instead of an exact match on the
'args' file, we 'grep' for the arguments other than the filename.
There is a deficiency in the current design. Windows has two kinds of
applications: GUI applications that start by "winmain()" and console
applications that start by "main()". Console applications are attached
to a new Console window if they are not already associated with a GUI
application. This means that every hour the scheudled task launches a
command window for the scheduled tasks. Not only is this visually
obtrusive, but it also takes focus from whatever else the user is
doing!
A simple fix would be to insert a GUI application that acts as a shim
between the scheduled task and Git. This is currently possible in Git
for Windows by setting the <Command> tag equal to
C:\Program Files\Git\git-bash.exe
with options "--hide --no-needs-console --command=cmd\git.exe"
followed by the arguments currently used. Since git-bash.exe is not
included in Windows builds of core Git, I chose to leave out this
feature. My plan is to submit a small patch to Git for Windows that
converts the use of git.exe with this use of git-bash.exe in the
short term. In the long term, we can consider creating this GUI
shim application within core Git, perhaps in contrib/.
Co-authored-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 13:08:28 +00:00
|
|
|
BACKGROUND MAINTENANCE ON WINDOWS SYSTEMS
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
Windows does not support `cron` and instead has its own system for
|
|
|
|
scheduling background tasks. The `git maintenance start` command uses
|
|
|
|
the `schtasks` command to submit tasks to this system. You can inspect
|
|
|
|
all background tasks using the Task Scheduler application. The tasks
|
|
|
|
added by Git have names of the form `Git Maintenance (<frequency>)`.
|
|
|
|
The Task Scheduler GUI has ways to inspect these tasks, but you can also
|
|
|
|
export the tasks to XML files and view the details there.
|
|
|
|
|
|
|
|
Note that since Git is a console application, these background tasks
|
|
|
|
create a console window visible to the current user. This can be changed
|
|
|
|
manually by selecting the "Run whether user is logged in or not" option
|
|
|
|
in Task Scheduler. This change requires a password input, which is why
|
|
|
|
`git maintenance start` does not select it by default.
|
|
|
|
|
|
|
|
If you want to customize the background tasks, please rename the tasks
|
|
|
|
so future calls to `git maintenance (start|stop)` do not overwrite your
|
|
|
|
custom tasks.
|
|
|
|
|
2020-10-15 17:22:04 +00:00
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-17 18:11:42 +00:00
|
|
|
GIT
|
|
|
|
---
|
|
|
|
Part of the linkgit:git[1] suite
|