Skip to content

Commit 25b3364

Browse files
committed
Merge branch 'ds/commit-graph-expiry-fix'
"git commit-graph write --expire-time=<timestamp>" did not use the given timestamp correctly, which has been corrected. * ds/commit-graph-expiry-fix: commit-graph: fix buggy --expire-time option
2 parents cc908db + b09b785 commit 25b3364

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

builtin/commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static int graph_write(int argc, const char **argv)
143143
OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple,
144144
N_("maximum ratio between two levels of a split commit-graph")),
145145
OPT_EXPIRY_DATE(0, "expire-time", &split_opts.expire_time,
146-
N_("maximum number of commits in a non-base split commit-graph")),
146+
N_("only expire files older than a given date-time")),
147147
OPT_END(),
148148
};
149149

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
17071707
timestamp_t expire_time = time(NULL);
17081708

17091709
if (ctx->split_opts && ctx->split_opts->expire_time)
1710-
expire_time -= ctx->split_opts->expire_time;
1710+
expire_time = ctx->split_opts->expire_time;
17111711
if (!ctx->split) {
17121712
char *chain_file_name = get_chain_filename(ctx->odb);
17131713
unlink(chain_file_name);

t/t5324-split-commit-graph.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,14 @@ test_expect_success 'test merge stragety constants' '
210210
git config core.commitGraph true &&
211211
test_line_count = 2 $graphdir/commit-graph-chain &&
212212
test_commit 15 &&
213-
git commit-graph write --reachable --split --size-multiple=10 --expire-time=1980-01-01 &&
213+
touch $graphdir/to-delete.graph $graphdir/to-keep.graph &&
214+
test-tool chmtime =1546362000 $graphdir/to-delete.graph &&
215+
test-tool chmtime =1546362001 $graphdir/to-keep.graph &&
216+
git commit-graph write --reachable --split --size-multiple=10 \
217+
--expire-time="2019-01-01 12:00 -05:00" &&
214218
test_line_count = 1 $graphdir/commit-graph-chain &&
219+
test_path_is_missing $graphdir/to-delete.graph &&
220+
test_path_is_file $graphdir/to-keep.graph &&
215221
ls $graphdir/graph-*.graph >graph-files &&
216222
test_line_count = 3 graph-files
217223
) &&

0 commit comments

Comments
 (0)