aboutsummaryrefslogtreecommitdiffstats
path: root/revision.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-02-22 21:25:07 -0500
committerJunio C Hamano <gitster@pobox.com>2021-02-22 23:30:52 -0800
commitc9fff0001699dd2862bf350146631fe53c1226d9 (patch)
tree5596f7944bbaf37f9b7726c70ef4e6c7195de743 /revision.c
parentf62312e02837d91e3b47ea876654bf3ac97b2905 (diff)
downloadgit-c9fff0001699dd2862bf350146631fe53c1226d9.tar.gz
revision: learn '--no-kept-objects'
A future caller will want to be able to perform a reachability traversal which terminates when visiting an object found in a kept pack. The closest existing option is '--honor-pack-keep', but this isn't quite what we want. Instead of halting the traversal midway through, a full traversal is always performed, and the results are only trimmed afterwords. Besides needing to introduce a new flag (since culling results post-facto can be different than halting the traversal as it's happening), there is an additional wrinkle handling the distinction in-core and on-disk kept packs. That is: what kinds of kept pack should stop the traversal? Introduce '--no-kept-objects[=<on-disk|in-core>]' to specify which kinds of kept packs, if any, should stop a traversal. This can be useful for callers that want to perform a reachability analysis, but want to leave certain packs alone (for e.g., when doing a geometric repack that has some "large" packs which are kept in-core that it wants to leave alone). Note that this option is not guaranteed to produce exactly the set of objects that aren't in kept packs, since it's possible the traversal order may end up in a situation where a non-kept ancestor was "cut off" by a kept object (at which point we would stop traversing). But, we don't care about absolute correctness here, since this will eventually be used as a purely additive guide in an upcoming new repack mode. Explicitly avoid documenting this new flag, since it is only used internally. In theory we could avoid even adding it rev-list, but being able to spell this option out on the command-line makes some special cases easier to test without promising to keep it behaving consistently forever. Those tricky cases are exercised in t6114. Signed-off-by: Taylor Blau <me@ttaylorr.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/revision.c b/revision.c
index b78733f508..dca2b8c801 100644
--- a/revision.c
+++ b/revision.c
@@ -2336,6 +2336,16 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->unpacked = 1;
} else if (starts_with(arg, "--unpacked=")) {
die(_("--unpacked=<packfile> no longer supported"));
+ } else if (!strcmp(arg, "--no-kept-objects")) {
+ revs->no_kept_objects = 1;
+ revs->keep_pack_cache_flags |= IN_CORE_KEEP_PACKS;
+ revs->keep_pack_cache_flags |= ON_DISK_KEEP_PACKS;
+ } else if (skip_prefix(arg, "--no-kept-objects=", &optarg)) {
+ revs->no_kept_objects = 1;
+ if (!strcmp(optarg, "in-core"))
+ revs->keep_pack_cache_flags |= IN_CORE_KEEP_PACKS;
+ if (!strcmp(optarg, "on-disk"))
+ revs->keep_pack_cache_flags |= ON_DISK_KEEP_PACKS;
} else if (!strcmp(arg, "-r")) {
revs->diff = 1;
revs->diffopt.flags.recursive = 1;
@@ -3795,6 +3805,11 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
return commit_ignore;
if (revs->unpacked && has_object_pack(&commit->object.oid))
return commit_ignore;
+ if (revs->no_kept_objects) {
+ if (has_object_kept_pack(&commit->object.oid,
+ revs->keep_pack_cache_flags))
+ return commit_ignore;
+ }
if (commit->object.flags & UNINTERESTING)
return commit_ignore;
if (revs->line_level_traverse && !want_ancestry(revs)) {