diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-01-18 13:49:53 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-18 13:49:53 -0800 |
commit | d01a3faa507cc06bd50889487ebab59f81702aa1 (patch) | |
tree | 04dc57b2d238514368df7a611021596515073a8a /commit-graph.c | |
parent | 540ee40e11a7b76eec7f9b4c14ab988345dc829e (diff) | |
parent | cce99cd8c677446820a895e827967ca56cae9a93 (diff) | |
download | git-d01a3faa507cc06bd50889487ebab59f81702aa1.tar.gz |
Merge branch 'ds/commit-graph-assert-missing-parents'
Tightening error checking in commit-graph writer.
* ds/commit-graph-assert-missing-parents:
commit-graph: writing missing parents is a BUG
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/commit-graph.c b/commit-graph.c index 5c8fb4b134..0d6ba6da2d 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -34,7 +34,6 @@ #define GRAPH_OID_LEN GRAPH_OID_LEN_SHA1 #define GRAPH_OCTOPUS_EDGES_NEEDED 0x80000000 -#define GRAPH_PARENT_MISSING 0x7fffffff #define GRAPH_EDGE_LAST_MASK 0x7fffffff #define GRAPH_PARENT_NONE 0x70000000 @@ -493,7 +492,9 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len, commit_to_sha1); if (edge_value < 0) - edge_value = GRAPH_PARENT_MISSING; + BUG("missing parent %s for commit %s", + oid_to_hex(&parent->item->object.oid), + oid_to_hex(&(*list)->object.oid)); } hashwrite_be32(f, edge_value); @@ -511,7 +512,9 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len, nr_commits, commit_to_sha1); if (edge_value < 0) - edge_value = GRAPH_PARENT_MISSING; + BUG("missing parent %s for commit %s", + oid_to_hex(&parent->item->object.oid), + oid_to_hex(&(*list)->object.oid)); } hashwrite_be32(f, edge_value); @@ -564,7 +567,9 @@ static void write_graph_chunk_large_edges(struct hashfile *f, commit_to_sha1); if (edge_value < 0) - edge_value = GRAPH_PARENT_MISSING; + BUG("missing parent %s for commit %s", + oid_to_hex(&parent->item->object.oid), + oid_to_hex(&(*list)->object.oid)); else if (!parent->next) edge_value |= GRAPH_LAST_EDGE; @@ -868,7 +873,7 @@ void write_commit_graph(const char *obj_dir, count_distinct++; } - if (count_distinct >= GRAPH_PARENT_MISSING) + if (count_distinct >= GRAPH_EDGE_LAST_MASK) die(_("the commit graph format cannot write %d commits"), count_distinct); commits.nr = 0; @@ -895,7 +900,7 @@ void write_commit_graph(const char *obj_dir, } num_chunks = num_extra_edges ? 4 : 3; - if (commits.nr >= GRAPH_PARENT_MISSING) + if (commits.nr >= GRAPH_EDGE_LAST_MASK) die(_("too many commits to write graph")); compute_generation_numbers(&commits, report_progress); |