Skip to content

[v2.23.0 BUG] commit-graph: fix bug around octopus merges #307

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

Conversation

derrickstolee
Copy link

@derrickstolee derrickstolee commented Aug 5, 2019

I come, hat in hand, with a bug-fix for a bug that I wrote. I just happened to discover this issue while playing around with turning the commit-graph on by default and stumbled into this warning.

Please see the commit message for full details, but putting octopus merges in a tip commit-graph file in the incremental format [1] would cause the file to not load because Git thinks the base commit-graphs do not have the right hashes.

It is very likely that a more careful patch would allow this warning to become an error during git commit-graph verify, but I wanted to minimize the change for this quick bug fix.

Thanks,
-Stolee

[1] https://public-inbox.org/git/pull.184.v6.git.gitgitgadget@gmail.com/

Cc: peff@peff.net, avarab@gmail.com, git@jeffhostetler.com, jrnieder@google.com, steadmon@google.com, johannes.schindelin@gmx.de, philipoakley@iee.org

@derrickstolee
Copy link
Author

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Aug 5, 2019

Submitted as pull.307.git.gitgitgadget@gmail.com

In 1771be9 "commit-graph: merge commit-graph chains" (2019-06-18),
the method sort_and_scan_merged_commits() was added to merge the
commit lists of two commit-graph files in the incremental format.
Unfortunately, there was an off-by-one error in that method around
incrementing num_extra_edges, which leads to an incorrect offset
for the base graph chunk.

When we store an octopus merge in the commit-graph file, we store
the first parent in the normal place, but use the second parent
position to point into the "extra edges" chunk where the remaining
parents exist. This means we should be adding "num_parents - 1"
edges to this list, not "num_parents - 2". That is the basic error.

The reason this was not caught in the test suite is more subtle.
In 5324-split-commit-graph.sh, we test creating an octopus merge
and adding it to the tip of a commit-graph chain, then verify the
result. This _should_ have caught the problem, except that when
we load the commit-graph files we were overly careful to not fail
when the commit-graph chain does not match. This care was on
purpose to avoid race conditions as one process reads the chain
and another process modifies it. In such a case, the reading
process outputs the following message to stderr:

	warning: commit-graph chain does not match

These warnings are output in the test suite, but ignored. By
checking the stderr of `git commit-graph verify` to include
the expected progress output, it will now catch this error.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@derrickstolee derrickstolee force-pushed the commit-graph-octopus-bug branch from 72b0630 to 6e913ac Compare August 5, 2019 15:04
@derrickstolee
Copy link
Author

I'm going to open a new PR and submit there, hopefully fixing whatever went wrong with GGG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant