> By using 'git commit-graph verify --shallow' we can ensure that > the file we just wrote is valid. This is an extra safety precaution > that is faster than our 'write' subcommand. In the rare situation > that the newest layer of the commit-graph is corrupt, we can "fix" > the corruption by deleting the commit-graph-chain file and rewrite > the full commit-graph as a new one-layer commit graph. This does > not completely prevent _that_ file from being corrupt, but it does > recompute the commit-graph by parsing commits from the object > database. In our use of this step in Scalar and VFS for Git, we > have only seen this issue arise because our microsoft/git fork > reverted 43d3561 ("commit-graph write: don't die if the existing > graph is corrupt" 2019-03-25) for a while to keep commit-graph > writes very fast. We dropped the revert when updating to v2.23.0. > The verify still has potential for catching corrupt data across > the layer boundary: if the new file has commit X with parent Y > in an old file but the commit ID for Y in the old file had a > bitswap, then we will notice that in the 'verify' command. I'm concerned about having this extra precaution, because it is never tested (neither here or in a future patch). When you saw this issue arise, was there ever an instance in which a valid set of commit graph files turned invalid after this maintenance step? (It seems from your description that the set was invalid to begin with, so the maintenance step did not fix it but also did not make it worse. And it does not make it worse, that seems not too bad to me.) Other than that, this patch looks good to me.