reachable.c: extract `obj_is_recent()`

When enumerating objects in order to add recent ones (i.e. those whose mtime is strictly newer than the cutoff) as tips of a reachability traversal, `add_recent_object()` discards objects which do not meet the recency criteria. The subsequent commit will make checking whether or not an object is recent also consult the list of hooks in `pack.recentHook`. Isolate this check in its own function to keep the additional complexity outside of `add_recent_object()`. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jun 7, 2023 at 18:58 UTC 01e9ca4a40e04cceeed01da05bed182556daa005
1 file changed +7 -1
reachable.c
+7 -1
@@ -69,6 +69,12 @@ struct recent_data {
69 int ignore_in_core_kept_packs;
70 };
71
72 +static int obj_is_recent(const struct object_id *oid, timestamp_t mtime,
73 + struct recent_data *data)
74 +{
75 + return mtime > data->timestamp;
76 +}
77 +
78 static void add_recent_object(const struct object_id *oid,
79 struct packed_git *pack,
80 off_t offset,
@@ -78,7 +84,7 @@ static void add_recent_object(const struct object_id *oid,
84 struct object *obj;
85 enum object_type type;
86
81 - if (mtime <= data->timestamp)
87 + if (!obj_is_recent(oid, mtime, data))
88 return;
89
90 /*