From: Junio C Hamano Date: Fri, 18 Jan 2019 21:49:53 +0000 (-0800) Subject: Merge branch 'ds/commit-graph-assert-missing-parents' X-Git-Tag: v2.21.0-rc0~95 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d01a3faa507cc06bd50889487ebab59f81702aa1?ds=inline;hp=-c 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 --- d01a3faa507cc06bd50889487ebab59f81702aa1 diff --combined commit-graph.c index 5c8fb4b134,c14ada6918..0d6ba6da2d --- a/commit-graph.c +++ b/commit-graph.c @@@ -34,7 -34,6 +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 @@@ -230,7 -229,8 +229,7 @@@ static void prepare_commit_graph_one(st */ static int prepare_commit_graph(struct repository *r) { - struct alternate_object_database *alt; - char *obj_dir; + struct object_directory *odb; int config_value; if (r->objects->commit_graph_attempted) @@@ -251,11 -251,13 +250,11 @@@ if (!commit_graph_compatible(r)) return 0; - obj_dir = r->objects->objectdir; - prepare_commit_graph_one(r, obj_dir); prepare_alt_odb(r); - for (alt = r->objects->alt_odb_list; - !r->objects->commit_graph && alt; - alt = alt->next) - prepare_commit_graph_one(r, alt->path); + for (odb = r->objects->odb; + !r->objects->commit_graph && odb; + odb = odb->next) + prepare_commit_graph_one(r, odb->path); return !!r->objects->commit_graph; } @@@ -493,7 -495,9 +492,9 @@@ static void write_graph_chunk_data(stru 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 -515,9 +512,9 @@@ 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 -570,9 +567,9 @@@ static void write_graph_chunk_large_edg 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; @@@ -638,29 -646,26 +643,29 @@@ static void add_missing_parents(struct static void close_reachable(struct packed_oid_list *oids, int report_progress) { - int i; + int i, j; struct commit *commit; struct progress *progress = NULL; - int j = 0; if (report_progress) progress = start_delayed_progress( - _("Annotating commits in commit graph"), 0); + _("Loading known commits in commit graph"), j = 0); for (i = 0; i < oids->nr; i++) { display_progress(progress, ++j); commit = lookup_commit(the_repository, &oids->list[i]); if (commit) commit->object.flags |= UNINTERESTING; } + stop_progress(&progress); /* * As this loop runs, oids->nr may grow, but not more * than the number of missing commits in the reachable * closure. */ + if (report_progress) + progress = start_delayed_progress( + _("Expanding reachable commits in commit graph"), j = 0); for (i = 0; i < oids->nr; i++) { display_progress(progress, ++j); commit = lookup_commit(the_repository, &oids->list[i]); @@@ -668,11 -673,7 +673,11 @@@ if (commit && !parse_commit(commit)) add_missing_parents(oids, commit); } + stop_progress(&progress); + if (report_progress) + progress = start_delayed_progress( + _("Clearing commit marks in commit graph"), j = 0); for (i = 0; i < oids->nr; i++) { display_progress(progress, ++j); commit = lookup_commit(the_repository, &oids->list[i]); @@@ -868,7 -869,7 +873,7 @@@ void write_commit_graph(const char *obj 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 -896,7 +900,7 @@@ } 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);