summaryrefslogtreecommitdiff
path: root/reachable.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2023-06-07 22:58:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-06-12 21:08:51 (GMT)
commit01e9ca4a40e04cceeed01da05bed182556daa005 (patch)
treedf068c3d32a54a3016b51ec7528a6cba15f2bf49 /reachable.c
parent69c786637d7a7fe3b2b8f7d989af095f5f49c3a8 (diff)
downloadgit-01e9ca4a40e04cceeed01da05bed182556daa005.zip
git-01e9ca4a40e04cceeed01da05bed182556daa005.tar.gz
git-01e9ca4a40e04cceeed01da05bed182556daa005.tar.bz2
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>
Diffstat (limited to 'reachable.c')
-rw-r--r--reachable.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/reachable.c b/reachable.c
index 55bb114..7a42da5 100644
--- a/reachable.c
+++ b/reachable.c
@@ -69,6 +69,12 @@ struct recent_data {
int ignore_in_core_kept_packs;
};
+static int obj_is_recent(const struct object_id *oid, timestamp_t mtime,
+ struct recent_data *data)
+{
+ return mtime > data->timestamp;
+}
+
static void add_recent_object(const struct object_id *oid,
struct packed_git *pack,
off_t offset,
@@ -78,7 +84,7 @@ static void add_recent_object(const struct object_id *oid,
struct object *obj;
enum object_type type;
- if (mtime <= data->timestamp)
+ if (!obj_is_recent(oid, mtime, data))
return;
/*