From: Jeff Hostetler Date: Thu, 02 Nov 2017 20:20:52 GMT Subject: [PATCH 9/9] gc: do not repack promisor packfiles Message-ID: <20171102202052.58762-10-git@jeffhostetler.com> In-Reply-To: <20171102202052.58762-1-git@jeffhostetler.com> From: Jonathan Tan Teach gc to stop traversal at promisor objects, and to leave promisor packfiles alone. This has the effect of only repacking non-promisor packfiles, and preserves the distinction between promisor packfiles and non-promisor packfiles. Signed-off-by: Jonathan Tan Signed-off-by: Jeff Hostetler --- Documentation/git-pack-objects.txt | 4 +++ builtin/gc.c | 4 +++ builtin/pack-objects.c | 14 ++++++++++ builtin/prune.c | 7 +++++ builtin/repack.c | 12 +++++++-- t/t0410-partial-clone.sh | 54 ++++++++++++++++++++++++++++++++++++-- 6 files changed, 91 insertions(+), 4 deletions(-) diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index 6786351..ee462c6 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -246,6 +246,10 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle. Ignore missing objects without error. This may be used with or without and of the above filtering. +--exclude-promisor-objects:: + Silently omit referenced but missing objects from the packfile. + This is used with partial clone. + SEE ALSO -------- linkgit:git-rev-list[1] diff --git a/builtin/gc.c b/builtin/gc.c index 3c5eae0..a17806a 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -20,6 +20,7 @@ #include "argv-array.h" #include "commit.h" #include "packfile.h" +#include "partial-clone-utils.h" #define FAILED_RUN "failed to run %s" @@ -458,6 +459,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix) argv_array_push(&prune, prune_expire); if (quiet) argv_array_push(&prune, "--no-progress"); + if (is_partial_clone_registered()) + argv_array_push(&prune, + "--exclude-promisor-objects"); if (run_command_v_opt(prune.argv, RUN_GIT_CMD)) return error(FAILED_RUN, prune.argv[0]); } diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index e16722f..957e459 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -83,6 +83,7 @@ static unsigned long window_memory_limit = 0; static struct list_objects_filter_options filter_options; static int arg_ignore_missing; +static int arg_exclude_promisor_objects; /* * stats @@ -2561,6 +2562,11 @@ static void show_object(struct object *obj, const char *name, void *data) if (arg_ignore_missing && !has_object_file(&obj->oid)) return; + if (arg_exclude_promisor_objects && + !has_object_file(&obj->oid) && + is_promisor_object(&obj->oid)) + return; + add_preferred_base_object(name); add_object_entry(obj->oid.hash, obj->type, name, 0); obj->flags |= OBJECT_ADDED; @@ -2972,6 +2978,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options), OPT_BOOL(0, "filter-ignore-missing", &arg_ignore_missing, N_("ignore and omit missing objects from packfile")), + OPT_BOOL(0, "exclude-promisor-objects", &arg_exclude_promisor_objects, + N_("do not pack objects in promisor packfiles")), OPT_END(), }; @@ -3017,6 +3025,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) argv_array_push(&rp, "--unpacked"); } + if (arg_exclude_promisor_objects) { + use_internal_rev_list = 1; + fetch_if_missing = 0; + argv_array_push(&rp, "--exclude-promisor-objects"); + } + if (!reuse_object) reuse_delta = 0; if (pack_compression_level == -1) diff --git a/builtin/prune.c b/builtin/prune.c index cddabf2..be34645 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -101,12 +101,15 @@ int cmd_prune(int argc, const char **argv, const char *prefix) { struct rev_info revs; struct progress *progress = NULL; + int exclude_promisor_objects = 0; const struct option options[] = { OPT__DRY_RUN(&show_only, N_("do not remove, show only")), OPT__VERBOSE(&verbose, N_("report pruned objects")), OPT_BOOL(0, "progress", &show_progress, N_("show progress")), OPT_EXPIRY_DATE(0, "expire", &expire, N_("expire objects older than