Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit-graph: fix buggy --expire-time option #255

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int graph_write(int argc, const char **argv)
OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple,
N_("maximum ratio between two levels of a split commit-graph")),
OPT_EXPIRY_DATE(0, "expire-time", &split_opts.expire_time,
N_("maximum number of commits in a non-base split commit-graph")),
N_("only expire files older than a given date-time")),
OPT_END(),
};

Expand Down
2 changes: 1 addition & 1 deletion commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,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;
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved
expire_time = ctx->split_opts->expire_time;
if (!ctx->split) {
char *chain_file_name = get_chain_filename(ctx->odb);
unlink(chain_file_name);
Expand Down
8 changes: 4 additions & 4 deletions t/t5319-multi-pack-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,10 @@ test_expect_success 'repack with minimum size does not alter existing packs' '
cd dup &&
rm -rf .git/objects/pack &&
mv .git/objects/pack-backup .git/objects/pack &&
touch -m -t 201901010000 .git/objects/pack/pack-D* &&
touch -m -t 201901010001 .git/objects/pack/pack-C* &&
touch -m -t 201901010002 .git/objects/pack/pack-B* &&
touch -m -t 201901010003 .git/objects/pack/pack-A* &&
test-tool chmtime =-5 .git/objects/pack/pack-D* &&
test-tool chmtime =-4 .git/objects/pack/pack-C* &&
test-tool chmtime =-3 .git/objects/pack/pack-B* &&
test-tool chmtime =-2 .git/objects/pack/pack-A* &&
ls .git/objects/pack >expect &&
MINSIZE=$(test-tool path-utils file-size .git/objects/pack/*pack | sort -n | head -n 1) &&
git multi-pack-index repack --batch-size=$MINSIZE &&
Expand Down
8 changes: 7 additions & 1 deletion t/t5324-split-commit-graph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,14 @@ test_expect_success 'test merge stragety constants' '
git config core.commitGraph true &&
test_line_count = 2 $graphdir/commit-graph-chain &&
test_commit 15 &&
git commit-graph write --reachable --split --size-multiple=10 --expire-time=1980-01-01 &&
touch $graphdir/to-delete.graph $graphdir/to-keep.graph &&
test-tool chmtime =1546362000 $graphdir/to-delete.graph &&
test-tool chmtime =1546362001 $graphdir/to-keep.graph &&
git commit-graph write --reachable --split --size-multiple=10 \
--expire-time="2019-01-01 12:00 -05:00" &&
test_line_count = 1 $graphdir/commit-graph-chain &&
test_path_is_missing $graphdir/to-delete.graph &&
test_path_is_file $graphdir/to-keep.graph &&
ls $graphdir/graph-*.graph >graph-files &&
test_line_count = 3 graph-files
) &&
Expand Down