Skip to content

Commit 52b8c8c

Browse files
committed
Merge branch 'ds/maintenance-part-2'
"git maintenance", an extended big brother of "git gc", continues to evolve. * ds/maintenance-part-2: maintenance: add incremental-repack auto condition maintenance: auto-size incremental-repack batch maintenance: add incremental-repack task midx: use start_delayed_progress() midx: enable core.multiPackIndex by default maintenance: create auto condition for loose-objects maintenance: add loose-objects task maintenance: add prefetch task
2 parents 26bb543 + e841a79 commit 52b8c8c

File tree

9 files changed

+603
-22
lines changed

9 files changed

+603
-22
lines changed

Documentation/config/core.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ core.useReplaceRefs::
606606

607607
core.multiPackIndex::
608608
Use the multi-pack-index file to track multiple packfiles using a
609-
single index. See link:technical/multi-pack-index.html[the
610-
multi-pack-index design document].
609+
single index. See linkgit:git-multi-pack-index[1] for more
610+
information. Defaults to true.
611611

612612
core.sparseCheckout::
613613
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]

Documentation/config/maintenance.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,21 @@ maintenance.commit-graph.auto::
1414
reachable commits that are not in the commit-graph file is at least
1515
the value of `maintenance.commit-graph.auto`. The default value is
1616
100.
17+
18+
maintenance.loose-objects.auto::
19+
This integer config option controls how often the `loose-objects` task
20+
should be run as part of `git maintenance run --auto`. If zero, then
21+
the `loose-objects` task will not run with the `--auto` option. A
22+
negative value will force the task to run every time. Otherwise, a
23+
positive value implies the command should run when the number of
24+
loose objects is at least the value of `maintenance.loose-objects.auto`.
25+
The default value is 100.
26+
27+
maintenance.incremental-repack.auto::
28+
This integer config option controls how often the `incremental-repack`
29+
task should be run as part of `git maintenance run --auto`. If zero,
30+
then the `incremental-repack` task will not run with the `--auto`
31+
option. A negative value will force the task to run every time.
32+
Otherwise, a positive value implies the command should run when the
33+
number of pack-files not in the multi-pack-index is at least the value
34+
of `maintenance.incremental-repack.auto`. The default value is 10.

Documentation/git-maintenance.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ commit-graph::
4747
`commit-graph-chain` file. They will be deleted by a later run based
4848
on the expiration delay.
4949

50+
prefetch::
51+
The `prefetch` task updates the object directory with the latest
52+
objects from all registered remotes. For each remote, a `git fetch`
53+
command is run. The refmap is custom to avoid updating local or remote
54+
branches (those in `refs/heads` or `refs/remotes`). Instead, the
55+
remote refs are stored in `refs/prefetch/<remote>/`. Also, tags are
56+
not updated.
57+
+
58+
This is done to avoid disrupting the remote-tracking branches. The end users
59+
expect these refs to stay unmoved unless they initiate a fetch. With prefetch
60+
task, however, the objects necessary to complete a later real fetch would
61+
already be obtained, so the real fetch would go faster. In the ideal case,
62+
it will just become an update to bunch of remote-tracking branches without
63+
any object transfer.
64+
5065
gc::
5166
Clean up unnecessary files and optimize the local repository. "GC"
5267
stands for "garbage collection," but this task performs many
@@ -55,6 +70,39 @@ gc::
5570
be disruptive in some situations, as it deletes stale data. See
5671
linkgit:git-gc[1] for more details on garbage collection in Git.
5772

73+
loose-objects::
74+
The `loose-objects` job cleans up loose objects and places them into
75+
pack-files. In order to prevent race conditions with concurrent Git
76+
commands, it follows a two-step process. First, it deletes any loose
77+
objects that already exist in a pack-file; concurrent Git processes
78+
will examine the pack-file for the object data instead of the loose
79+
object. Second, it creates a new pack-file (starting with "loose-")
80+
containing a batch of loose objects. The batch size is limited to 50
81+
thousand objects to prevent the job from taking too long on a
82+
repository with many loose objects. The `gc` task writes unreachable
83+
objects as loose objects to be cleaned up by a later step only if
84+
they are not re-added to a pack-file; for this reason it is not
85+
advisable to enable both the `loose-objects` and `gc` tasks at the
86+
same time.
87+
88+
incremental-repack::
89+
The `incremental-repack` job repacks the object directory
90+
using the `multi-pack-index` feature. In order to prevent race
91+
conditions with concurrent Git commands, it follows a two-step
92+
process. First, it calls `git multi-pack-index expire` to delete
93+
pack-files unreferenced by the `multi-pack-index` file. Second, it
94+
calls `git multi-pack-index repack` to select several small
95+
pack-files and repack them into a bigger one, and then update the
96+
`multi-pack-index` entries that refer to the small pack-files to
97+
refer to the new pack-file. This prepares those small pack-files
98+
for deletion upon the next run of `git multi-pack-index expire`.
99+
The selection of the small pack-files is such that the expected
100+
size of the big pack-file is at least the batch size; see the
101+
`--batch-size` option for the `repack` subcommand in
102+
linkgit:git-multi-pack-index[1]. The default batch-size is zero,
103+
which is a special case that attempts to repack all pack-files
104+
into a single pack-file.
105+
58106
OPTIONS
59107
-------
60108
--auto::

0 commit comments

Comments
 (0)