]> git.ipfire.org Git - thirdparty/git.git/commit - commit-graph.c
commit-graph: normalize commit-graph filenames
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 18 Jun 2019 18:14:36 +0000 (11:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jun 2019 03:46:27 +0000 (20:46 -0700)
commit16110c9348fc2022e78f2581968cf428c056dc5b
tree0bf8c25303b5893adc12a8ed3deb23ca3d94ee81
parenta09c1301ce5986a374ab008b2125fa26a9bdd2fe
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 <obj-dir>/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 <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c
t/t5324-split-commit-graph.sh