]> git.ipfire.org Git - thirdparty/git.git/commit - commit-graph.h
commit-graph: write commit-graph chains
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 18 Jun 2019 18:14:27 +0000 (11:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jun 2019 03:46:26 +0000 (20:46 -0700)
commit6c622f9f0bbb38a23341dc4294f56d0d909b3d50
treed9e05c4508dfab644d1d897d548ad408bb352fc1
parent144354b054c99b2231be6bae517eed5f8da55268
commit-graph: write commit-graph chains

Extend write_commit_graph() to write a commit-graph chain when given the
COMMIT_GRAPH_SPLIT flag.

This implementation is purposefully simplistic in how it creates a new
chain. The commits not already in the chain are added to a new tip
commit-graph file.

Much of the logic around writing a graph-{hash}.graph file and updating
the commit-graph-chain file is the same as the commit-graph file case.
However, there are several places where we need to do some extra logic
in the split case.

Track the list of graph filenames before and after the planned write.
This will be more important when we start merging graph files, but it
also allows us to upgrade our commit-graph file to the appropriate
graph-{hash}.graph file when we upgrade to a chain of commit-graphs.

Note that we use the eighth byte of the commit-graph header to store the
number of base graph files. This determines the length of the base
graphs chunk.

A subtle change of behavior with the new logic is that we do not write a
commit-graph if we our commit list is empty. This extends to the typical
case, which is reflected in t5318-commit-graph.sh.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c
commit-graph.h
t/t5318-commit-graph.sh