From 16110c9348fc2022e78f2581968cf428c056dc5b Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 18 Jun 2019 11:14:36 -0700 Subject: commit-graph: normalize commit-graph filenames When writing commit-graph files, we append path data to an object directory, which may be specified by the user via the '--object-dir' option. If the user supplies a trailing slash, or some other alternative path format, the resulting path may be usable for writing to the correct location. However, when expiring graph files from the /info/commit-graphs directory during a write, we need to compare paths with exact string matches. Normalize the commit-graph filenames to avoid ambiguity. This creates extra allocations, but this is a constant multiple of the number of commit-graph files, which should be a number in the single digits. Further normalize the object directory in the context. Due to a comparison between g->obj_dir and ctx->obj_dir in split_graph_merge_strategy(), a trailing slash would prevent any merging of layers within the same object directory. The check is there to ensure we do not merge across alternates. Update the tests to include a case with this trailing slash problem. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- t/t5324-split-commit-graph.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 't/t5324-split-commit-graph.sh') diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh index 130f2baf44..fc0d00751c 100755 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@ -163,7 +163,12 @@ test_expect_success 'create fork and chain across alternate' ' test_line_count = 1 graph-files && git -c core.commitGraph=true rev-list HEAD >expect && git -c core.commitGraph=false rev-list HEAD >actual && - test_cmp expect actual + test_cmp expect actual && + test_commit 14 && + git commit-graph write --reachable --split --object-dir=.git/objects/ && + test_line_count = 3 $graphdir/commit-graph-chain && + ls $graphdir/graph-*.graph >graph-files && + test_line_count = 1 graph-files ) ' -- cgit v1.3