commit-graph: fix buggy --expire-time option
The commit-graph builtin has an --expire-time option that takes a datetime using OPT_EXPIRY_DATE(). However, the implementation inside expire_commit_graphs() was treating a non-zero value as a number of seconds to subtract from "now". Update t5323-split-commit-graph.sh to demonstrate the correct value of the --expire-time option by actually creating a crud .graph file with mtime earlier than the expire time. Instead of using a super- early time (1980) we use an explicit, and recent, time. Using test-tool chmtime to create two files on either end of an exact second, we create a test that catches this failure no matter the current time. Using a fixed date is more portable than trying to format a relative date string into the --expiry-date input. I noticed this when inspecting some Scalar repos that had an excess number of commit-graph files. In Scalar, we were using this second interpretation by using "--expire-time=3600" to mean "delete graphs older than one hour ago" to avoid deleting a commit-graph that a foreground process may be trying to load. Also I noticed that the help text was copied from the --max-commits option. Fix that help text. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5b15eb397d
commit
b09b785c78
@ -1694,7 +1694,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
|
||||
timestamp_t expire_time = time(NULL);
|
||||
|
||||
if (ctx->split_opts && ctx->split_opts->expire_time)
|
||||
expire_time -= ctx->split_opts->expire_time;
|
||||
expire_time = ctx->split_opts->expire_time;
|
||||
if (!ctx->split) {
|
||||
char *chain_file_name = get_chain_filename(ctx->obj_dir);
|
||||
unlink(chain_file_name);
|
||||
|
Reference in New Issue
Block a user