Merge branch 'tb/commit-graph-genv2-upgrade-fix'

There was a bug in the codepath to upgrade generation information
in commit-graph from v1 to v2 format, which has been corrected.

* tb/commit-graph-genv2-upgrade-fix:
  commit-graph: fix corrupt upgrade from generation v1 to v2
  commit-graph: introduce `repo_find_commit_pos_in_graph()`
  t5318: demonstrate commit-graph generation v2 corruption
This commit is contained in:
Junio C Hamano
2022-08-03 13:36:08 -07:00
4 changed files with 56 additions and 8 deletions

View File

@ -40,6 +40,21 @@ int open_commit_graph(const char *graph_file, int *fd, struct stat *st);
*/
int parse_commit_in_graph(struct repository *r, struct commit *item);
/*
* Fills `*pos` with the graph position of `c`, and returns 1 if `c` is
* found in the commit-graph belonging to `r`, or 0 otherwise.
* Initializes the commit-graph belonging to `r` if it hasn't been
* already.
*
* Note: this is a low-level helper that does not alter any slab data
* associated with `c`. Useful in circumstances where the slab data is
* already being modified (e.g., writing the commit-graph itself).
*
* In most cases, callers should use `parse_commit_in_graph()` instead.
*/
int repo_find_commit_pos_in_graph(struct repository *r, struct commit *c,
uint32_t *pos);
/*
* Look up the given commit ID in the commit-graph. This will only return a
* commit if the ID exists both in the graph and in the object database such