Skip to content

Commit d01a3fa

Browse files
committed
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
2 parents 540ee40 + cce99cd commit d01a3fa

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

commit-graph.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#define GRAPH_OID_LEN GRAPH_OID_LEN_SHA1
3535

3636
#define GRAPH_OCTOPUS_EDGES_NEEDED 0x80000000
37-
#define GRAPH_PARENT_MISSING 0x7fffffff
3837
#define GRAPH_EDGE_LAST_MASK 0x7fffffff
3938
#define GRAPH_PARENT_NONE 0x70000000
4039

@@ -493,7 +492,9 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
493492
commit_to_sha1);
494493

495494
if (edge_value < 0)
496-
edge_value = GRAPH_PARENT_MISSING;
495+
BUG("missing parent %s for commit %s",
496+
oid_to_hex(&parent->item->object.oid),
497+
oid_to_hex(&(*list)->object.oid));
497498
}
498499

499500
hashwrite_be32(f, edge_value);
@@ -511,7 +512,9 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
511512
nr_commits,
512513
commit_to_sha1);
513514
if (edge_value < 0)
514-
edge_value = GRAPH_PARENT_MISSING;
515+
BUG("missing parent %s for commit %s",
516+
oid_to_hex(&parent->item->object.oid),
517+
oid_to_hex(&(*list)->object.oid));
515518
}
516519

517520
hashwrite_be32(f, edge_value);
@@ -564,7 +567,9 @@ static void write_graph_chunk_large_edges(struct hashfile *f,
564567
commit_to_sha1);
565568

566569
if (edge_value < 0)
567-
edge_value = GRAPH_PARENT_MISSING;
570+
BUG("missing parent %s for commit %s",
571+
oid_to_hex(&parent->item->object.oid),
572+
oid_to_hex(&(*list)->object.oid));
568573
else if (!parent->next)
569574
edge_value |= GRAPH_LAST_EDGE;
570575

@@ -868,7 +873,7 @@ void write_commit_graph(const char *obj_dir,
868873
count_distinct++;
869874
}
870875

871-
if (count_distinct >= GRAPH_PARENT_MISSING)
876+
if (count_distinct >= GRAPH_EDGE_LAST_MASK)
872877
die(_("the commit graph format cannot write %d commits"), count_distinct);
873878

874879
commits.nr = 0;
@@ -895,7 +900,7 @@ void write_commit_graph(const char *obj_dir,
895900
}
896901
num_chunks = num_extra_edges ? 4 : 3;
897902

898-
if (commits.nr >= GRAPH_PARENT_MISSING)
903+
if (commits.nr >= GRAPH_EDGE_LAST_MASK)
899904
die(_("too many commits to write graph"));
900905

901906
compute_generation_numbers(&commits, report_progress);

0 commit comments

Comments
 (0)