diff options
| author | Robert Coup <robert@coup.net.nz> | 2022-03-28 14:02:10 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-03-28 10:25:53 -0700 |
| commit | 7390f05a3c674e354ba2f52632046fa0a5c3e501 (patch) | |
| tree | 2b4cd1de6a82779dfeb39a08ad845f5a1b5c36d5 /builtin | |
| parent | t5615-partial-clone: add test for fetch --refetch (diff) | |
| download | git-7390f05a3c674e354ba2f52632046fa0a5c3e501.tar.gz git-7390f05a3c674e354ba2f52632046fa0a5c3e501.zip | |
fetch: after refetch, encourage auto gc repacking
After invoking `fetch --refetch`, the object db will likely contain many
duplicate objects. If auto-maintenance is enabled, invoke it with
appropriate settings to encourage repacking/consolidation.
* gc.autoPackLimit: unless this is set to 0 (disabled), override the
value to 1 to force pack consolidation.
* maintenance.incremental-repack.auto: unless this is set to 0, override
the value to -1 to force incremental repacking.
Signed-off-by: Robert Coup <robert@coup.net.nz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/fetch.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index aa53ada58a..a47b696b89 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2226,8 +2226,25 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) NULL); } - if (enable_auto_gc) + if (enable_auto_gc) { + if (refetch) { + /* + * Hint auto-maintenance strongly to encourage repacking, + * but respect config settings disabling it. + */ + int opt_val; + if (git_config_get_int("gc.autopacklimit", &opt_val)) + opt_val = -1; + if (opt_val != 0) + git_config_push_parameter("gc.autoPackLimit=1"); + + if (git_config_get_int("maintenance.incremental-repack.auto", &opt_val)) + opt_val = -1; + if (opt_val != 0) + git_config_push_parameter("maintenance.incremental-repack.auto=-1"); + } run_auto_maintenance(verbosity < 0); + } cleanup: string_list_clear(&list, 0); |
