commit eed86c18e9c3083942c1f28f02fd2ee3b1b0b6f08d28fb21ad6137e5ebaf5ff9 from: Stefan Sperling date: Mon Aug 4 13:27:51 2025 UTC remove code which repaints parent commits from commit coloring implementation Two pack tests start failing. This will be fixed in the next commit. ok op@ commit - 2b8971e9587632dce16bc7caf465d3414002ea5861eefdc47bf0c2b12dbd0a54 commit + eed86c18e9c3083942c1f28f02fd2ee3b1b0b6f08d28fb21ad6137e5ebaf5ff9 blob - 39f98d11fa02f0aeca9a4615bb537e46410de5e42ef802c16e7414baf40ad395 blob + ccb247a294c1243f0a1115837da4b96cf3d2cbc89bdf52d7cce2a7bcdf01d577 --- lib/got_lib_pack_create.h +++ lib/got_lib_pack_create.h @@ -55,9 +55,6 @@ enum got_pack_findtwixt_color { const struct got_error *got_pack_paint_commit(struct got_object_qid *qid, intptr_t color); -const struct got_error *got_pack_repaint_parent_commits( - struct got_object_id *commit_id, int color, struct got_object_idset *set, - struct got_object_idset *skip, struct got_repository *repo); const struct got_error *got_pack_queue_commit_id( struct got_object_id_queue *ids, struct got_object_id *id, intptr_t color, struct got_repository *repo); blob - 4dbf60a7983658d4b7293ac2a67db69de21aaadfa0596a063e07b6db59fe8809 blob + c41fed1755630293011b8cc1366dcd683123efc3b4e5a12515923170217bf502 --- lib/pack_create.c +++ lib/pack_create.c @@ -1049,87 +1049,6 @@ got_pack_paint_commit(struct got_object_qid *qid, intp } const struct got_error * -got_pack_repaint_parent_commits(struct got_object_id *commit_id, int color, - struct got_object_idset *set, struct got_object_idset *skip, - struct got_repository *repo) -{ - const struct got_error *err = NULL; - struct got_object_id_queue ids; - struct got_object_qid *qid = NULL; - struct got_commit_object *commit = NULL; - const struct got_object_id_queue *parents; - struct got_object_idset *traversed; - - STAILQ_INIT(&ids); - - traversed = got_object_idset_alloc(); - if (traversed == NULL) - return got_error_from_errno("got_object_idset_alloc"); - - err = got_object_open_as_commit(&commit, repo, commit_id); - if (err) - return err; - - while (commit) { - parents = got_object_commit_get_parent_ids(commit); - if (parents) { - struct got_object_qid *pid; - STAILQ_FOREACH(pid, parents, entry) { - /* - * No need to traverse parents which are - * already in the desired set or are - * marked for skipping already. - */ - if (got_object_idset_contains(set, &pid->id)) - continue; - if (skip != set && - got_object_idset_contains(skip, &pid->id)) - continue; - - if (got_object_idset_contains(traversed, - &pid->id)) - continue; - err = got_pack_queue_commit_id(&ids, &pid->id, - color, repo); - if (err) - break; - err = got_object_idset_add(traversed, - &pid->id, NULL); - if (err) - goto done; - } - } - got_object_commit_close(commit); - commit = NULL; - - qid = STAILQ_FIRST(&ids); - if (qid == NULL) - break; - - STAILQ_REMOVE_HEAD(&ids, entry); - err = got_object_idset_add(set, &qid->id, NULL); - if (err) - break; - - err = got_object_open_as_commit(&commit, repo, &qid->id); - if (err) - break; - - got_object_qid_free(qid); - qid = NULL; - } -done: - if (commit) - got_object_commit_close(commit); - if (qid) - got_object_qid_free(qid); - got_object_id_queue_free(&ids); - got_object_idset_free(traversed); - - return err; -} - -const struct got_error * got_pack_queue_commit_id(struct got_object_id_queue *ids, struct got_object_id *id, intptr_t color, struct got_repository *repo) { blob - 26f201ecc5bf5a410862aa8dafbeb13a507fb5dc493625cf487d3a849193b50a blob + 683186c4566d281e59cc998207db0dea90c61a64747efcfa78ffab0aa3cd699c --- lib/pack_create_io.c +++ lib/pack_create_io.c @@ -282,10 +282,6 @@ got_pack_paint_commits(int *ncolored, struct got_objec NULL); if (err) goto done; - err = got_pack_repaint_parent_commits(&qid->id, - COLOR_SKIP, skip, skip, repo); - if (err) - goto done; } else (*ncolored)++; err = got_object_idset_add(keep, &qid->id, NULL); @@ -301,10 +297,6 @@ got_pack_paint_commits(int *ncolored, struct got_objec NULL); if (err) goto done; - err = got_pack_repaint_parent_commits(&qid->id, - COLOR_SKIP, skip, skip, repo); - if (err) - goto done; } else (*ncolored)++; err = got_object_idset_add(drop, &qid->id, NULL); blob - 45bcb406586828fdb27cdef4f8d84a3307f78c41be92e5beabd496436ceb441a blob + 9d4f6c90552283f25b093fae7c37e1cfc3c5ff6448e6cd8e98992274cc3f0310 --- lib/pack_create_privsep.c +++ lib/pack_create_privsep.c @@ -538,10 +538,6 @@ got_pack_paint_commits(int *ncolored, struct got_objec NULL); if (err) goto done; - err = got_pack_repaint_parent_commits(&qid->id, - COLOR_SKIP, skip, skip, repo); - if (err) - goto done; } else (*ncolored)++; err = got_object_idset_add(keep, &qid->id, NULL); @@ -557,10 +553,6 @@ got_pack_paint_commits(int *ncolored, struct got_objec NULL); if (err) goto done; - err = got_pack_repaint_parent_commits(&qid->id, - COLOR_SKIP, skip, skip, repo); - if (err) - goto done; } else (*ncolored)++; err = got_object_idset_add(drop, &qid->id, NULL); blob - 2d92ca80bd13be8ecaf7e5a7d33d5530cc85e131f7455e8d3a8d17da1eda6005 blob + d8ee76157b52499f8695da19ccab1988d8aea57619ee814e202c311e8b4e55b7 --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -1681,141 +1681,6 @@ queue_commit_id(struct got_object_id_queue *ids, struc } static const struct got_error * -repaint_parent_commits(struct got_object_id *commit_id, int commit_idx, - int color, struct got_object_idset *set, struct got_object_idset *skip, - struct got_object_id_queue *ids, int *nids, - struct got_object_id_queue *painted, int *npainted, - struct got_pack *pack, struct got_packidx *packidx, - struct got_object_cache *objcache) -{ - const struct got_error *err = NULL; - const struct got_object_id_queue *parents; - struct got_commit_object *commit = NULL; - struct got_object_id_queue repaint; - struct got_object_idset *traversed; - - STAILQ_INIT(&repaint); - - traversed = got_object_idset_alloc(); - if (traversed == NULL) - return got_error_from_errno("got_object_idset_alloc"); - - err = open_commit(&commit, pack, packidx, commit_idx, commit_id, - objcache); - if (err) - return err; - - while (commit) { - struct got_object_qid *pid, *qid; - int idx; - - if (sigint_received) { - err = got_error(GOT_ERR_CANCELLED); - goto done; - } - - parents = got_object_commit_get_parent_ids(commit); - if (parents) { - STAILQ_FOREACH(pid, parents, entry) { - idx = got_packidx_get_object_idx(packidx, - &pid->id); - /* - * No need to traverse parents which are not in - * the pack file, are already in the desired - * set, or are marked for skipping already. - */ - if (idx == -1) - continue; - if (got_object_idset_contains(set, &pid->id)) - continue; - if (set != skip && - got_object_idset_contains(skip, &pid->id)) - continue; - - if (got_object_idset_contains(traversed, - &pid->id)) - continue; - err = queue_commit_id(&repaint, &pid->id, - color); - if (err) - goto done; - err = got_object_idset_add(traversed, - &pid->id, NULL); - if (err) - goto done; - } - } - got_object_commit_close(commit); - commit = NULL; - - pid = STAILQ_FIRST(&repaint); - if (pid == NULL) - break; - - err = paint_commit(pid, color); - if (err) - break; - - err = got_object_idset_add(set, &pid->id, NULL); - if (err) - break; - - STAILQ_REMOVE_HEAD(&repaint, entry); - - /* Insert or replace this commit on the painted list. */ - STAILQ_FOREACH(qid, painted, entry) { - if (got_object_id_cmp(&qid->id, &pid->id) != 0) - continue; - err = paint_commit(qid, color); - if (err) - goto done; - got_object_qid_free(pid); - pid = qid; - break; - } - if (qid == NULL) { - STAILQ_INSERT_TAIL(painted, pid, entry); - (*npainted)++; - } - - /* - * In case this commit is on the caller's list of - * pending commits to traverse, repaint it there. - */ - STAILQ_FOREACH(qid, ids, entry) { - if (got_object_id_cmp(&qid->id, &pid->id) != 0) - continue; - err = paint_commit(qid, color); - if (err) - goto done; - break; - } - - idx = got_packidx_get_object_idx(packidx, &pid->id); - if (idx == -1) { - /* - * Should not happen because we only queue - * parents which exist in our pack file. - */ - err = got_error(GOT_ERR_NO_OBJ); - break; - } - - err = open_commit(&commit, pack, packidx, idx, &pid->id, - objcache); - if (err) - break; - } -done: - if (commit) - got_object_commit_close(commit); - got_object_id_queue_free(&repaint); - got_object_idset_free(traversed); - - return err; -} - -static const struct got_error * paint_commits(struct got_object_id_queue *ids, int *nids, struct got_object_idset *keep, struct got_object_idset *drop, struct got_object_idset *skip, struct got_pack *pack, @@ -1881,12 +1746,6 @@ paint_commits(struct got_object_id_queue *ids, int *ni NULL); if (err) goto done; - err = repaint_parent_commits(&qid->id, idx, - COLOR_SKIP, skip, skip, ids, nids, - &painted, &npainted, pack, packidx, - objcache); - if (err) - goto done; break; } if (!got_object_idset_contains(keep, &qid->id)) { @@ -1905,12 +1764,6 @@ paint_commits(struct got_object_id_queue *ids, int *ni NULL); if (err) goto done; - err = repaint_parent_commits(&qid->id, idx, - COLOR_SKIP, skip, skip, ids, nids, - &painted, &npainted, pack, packidx, - objcache); - if (err) - goto done; break; } if (!got_object_idset_contains(drop, &qid->id)) {