@@ -413,6 +413,10 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix)
struct remote_bundle_info *stack = NULL;
struct hashmap toc = { 0 };
const char *filter = NULL;
+ const char *timestamp_key = "fetch.bundletimestamp";
+ timestamp_t stored_time = 0;
+ timestamp_t max_time = 0;
+ const char *value;
struct option options[] = {
OPT_BOOL(0, "progress", &progress,
@@ -428,6 +432,17 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix)
if (!startup_info->have_repository)
die(_("'fetch' requires a repository"));
+ /*
+ * TODO: Is it important re
+ * https://lore.kernel.org/git/220311.86pmmshahy.gmgdl@evledraar.gmail.com/
+ * that we don't accept "2.days.ago" etc., and only *nix
+ * epochs?
+ */
+ if (!git_config_get_string_tmp(timestamp_key, &value) &&
+ parse_expiry_date(value, &stored_time))
+ return error(_("'%s' for '%s' is not a valid timestamp"),
+ value, timestamp_key);
+
/*
* Step 1: determine protocol for uri, and download contents to
* a temporary location.
@@ -449,7 +464,6 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix)
} else {
struct hashmap_iter iter;
struct remote_bundle_info *info;
- timestamp_t max_time = 0;
/* populate a hashtable with all relevant bundles. */
used_hashmap = 1;
@@ -480,6 +494,13 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix)
max_time = info->timestamp;
}
}
+
+ trace2_data_intmax("bundle", the_repository, "max_time", max_time);
+ trace2_data_intmax("bundle", the_repository, "stored_time", stored_time);
+
+ /* Skip fetching bundles if data isn't new enough. */
+ if (max_time <= stored_time)
+ goto cleanup;
}
/*
@@ -567,6 +588,14 @@ static int cmd_bundle_fetch(int argc, const char **argv, const char *prefix)
stack = stack->stack_next;
}
+ if (max_time) {
+ struct strbuf tstr = STRBUF_INIT;
+ strbuf_addf(&tstr, "%"PRIuMAX"", max_time);
+ git_config_set_gently(timestamp_key, tstr.buf);
+ strbuf_release(&tstr);
+ }
+
+cleanup:
if (used_hashmap) {
struct hashmap_iter iter;
struct remote_bundle_info *info;