commit 79f35eb3b4364a05179d249cab971e1cd4f061aa from: Stefan Sperling date: Mon Jun 11 01:09:27 2018 UTC rename got_parent_id to got_object_qid; better generic name commit - b43fbaa0226c6bbb53e5b4aff76b279178ec2227 commit + 79f35eb3b4364a05179d249cab971e1cd4f061aa blob - e89b38006a253fdb957859f3cb8444263a2d9f82 blob + a4853d1c44dc55fe3b7d7692fc1b6a493db06a96 --- got/got.c +++ got/got.c @@ -265,7 +265,7 @@ print_patch(struct got_commit_object *commit, struct g const struct got_error *err = NULL; struct got_tree_object *tree1 = NULL, *tree2; struct got_object *obj; - struct got_parent_id *pid; + struct got_object_qid *qid; err = got_object_open(&obj, repo, commit->tree_id); if (err) @@ -276,11 +276,11 @@ print_patch(struct got_commit_object *commit, struct g if (err) return err; - pid = SIMPLEQ_FIRST(&commit->parent_ids); - if (pid != NULL) { + qid = SIMPLEQ_FIRST(&commit->parent_ids); + if (qid != NULL) { struct got_commit_object *pcommit; - err = got_object_open(&obj, repo, pid->id); + err = got_object_open(&obj, repo, qid->id); if (err) return err; @@ -342,10 +342,10 @@ print_commit(struct got_commit_object *commit, struct datestr, commit->committer_tzoff); } if (commit->nparents > 1) { - struct got_parent_id *pid; + struct got_object_qid *qid; int n = 1; - SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) { - err = got_object_id_str(&id_str, pid->id); + SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + err = got_object_id_str(&id_str, qid->id); if (err) return err; printf("parent %d: %s\n", n++, id_str); blob - 9eb68be64d5972c9b6fd5d06be9ec7516376f1dd blob + a3645205361df169a60345d7d35787b6b79dd37c --- include/got_object.h +++ include/got_object.h @@ -30,17 +30,17 @@ struct got_tree_object { SIMPLEQ_HEAD(, got_tree_entry) entries; }; -struct got_parent_id { - SIMPLEQ_ENTRY(got_parent_id) entry; +struct got_object_qid { + SIMPLEQ_ENTRY(got_object_qid) entry; struct got_object_id *id; }; -SIMPLEQ_HEAD(got_object_id_list, got_parent_id); +SIMPLEQ_HEAD(got_object_id_queue, got_object_qid); struct got_commit_object { struct got_object_id *tree_id; unsigned int nparents; - struct got_object_id_list parent_ids; + struct got_object_id_queue parent_ids; char *author; time_t author_time; /* local time */ char *author_tzoff; /* timezone offset description */ blob - 53c0fcf6c5234c7892715e7eed9a849c06977991 blob + 5fb439cf2ac937396e49f91d4a55d40e4735c38d --- lib/commit_graph.c +++ lib/commit_graph.c @@ -45,9 +45,9 @@ struct got_commit_graph_node { * and child (younger) commits. */ int nparents; - struct got_object_id_list parent_ids; + struct got_object_id_queue parent_ids; int nchildren; - struct got_object_id_list child_ids; + struct got_object_id_queue child_ids; time_t commit_timestamp; @@ -168,22 +168,22 @@ add_iteration_candidate(struct got_commit_graph *graph } static const struct got_error * -add_vertex(struct got_object_id_list *id_list, struct got_object_id *id) +add_vertex(struct got_object_id_queue *ids, struct got_object_id *id) { - struct got_parent_id *pid; + struct got_object_qid *qid; - pid = calloc(1, sizeof(*pid)); - if (pid == NULL) + qid = calloc(1, sizeof(*qid)); + if (qid == NULL) return got_error_from_errno(); - pid->id = got_object_id_dup(id); - if (pid->id == NULL) { + qid->id = got_object_id_dup(id); + if (qid->id == NULL) { const struct got_error *err = got_error_from_errno(); - free(pid); + free(qid); return err; } - SIMPLEQ_INSERT_TAIL(id_list, pid, entry); + SIMPLEQ_INSERT_TAIL(ids, qid, entry); return NULL; } @@ -194,7 +194,7 @@ add_node(struct got_commit_graph_node **new_node, { const struct got_error *err = NULL; struct got_commit_graph_node *node, *existing_node; - struct got_parent_id *pid; + struct got_object_qid *qid; *new_node = NULL; @@ -205,8 +205,8 @@ add_node(struct got_commit_graph_node **new_node, memcpy(&node->id, commit_id, sizeof(node->id)); SIMPLEQ_INIT(&node->parent_ids); SIMPLEQ_INIT(&node->child_ids); - SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) { - err = add_vertex(&node->parent_ids, pid->id); + SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + err = add_vertex(&node->parent_ids, qid->id); if (err) return err; node->nparents++; @@ -216,17 +216,17 @@ add_node(struct got_commit_graph_node **new_node, err = got_object_idset_add((void **)(&existing_node), graph->node_ids, &node->id, node); if (err == NULL) { - struct got_parent_id *pid; + struct got_object_qid *qid; add_iteration_candidate(graph, node); err = got_object_idset_remove(graph->open_branches, commit_id); if (err && err->code != GOT_ERR_NO_OBJ) return err; - SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) { - if (got_object_idset_get(graph->node_ids, pid->id)) + SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + if (got_object_idset_get(graph->node_ids, qid->id)) continue; /* parent already traversed */ err = got_object_idset_add(NULL, graph->open_branches, - pid->id, node); + qid->id, node); if (err && err->code != GOT_ERR_OBJ_EXISTS) return err; } @@ -241,7 +241,7 @@ add_node(struct got_commit_graph_node **new_node, } if (child_commit_id) { - struct got_parent_id *cid; + struct got_object_qid *cid; /* Prevent linking to self. */ if (got_object_id_cmp(commit_id, child_commit_id) == 0) @@ -425,7 +425,7 @@ free_graph_node(struct got_object_id *id, void *data, { struct got_commit_graph_node *node = data; while (!SIMPLEQ_EMPTY(&node->child_ids)) { - struct got_parent_id *child = SIMPLEQ_FIRST(&node->child_ids); + struct got_object_qid *child = SIMPLEQ_FIRST(&node->child_ids); SIMPLEQ_REMOVE_HEAD(&node->child_ids, entry); free(child); } @@ -446,7 +446,7 @@ got_commit_graph_iter_start(struct got_commit_graph *g struct got_object_id *id) { struct got_commit_graph_node *start_node, *node; - struct got_parent_id *pid; + struct got_object_qid *qid; start_node = got_object_idset_get(graph->node_ids, id); if (start_node == NULL) @@ -460,8 +460,8 @@ got_commit_graph_iter_start(struct got_commit_graph *g } /* Put all known parents of this commit on the candidate list. */ - SIMPLEQ_FOREACH(pid, &start_node->parent_ids, entry) { - node = got_object_idset_get(graph->node_ids, pid->id); + SIMPLEQ_FOREACH(qid, &start_node->parent_ids, entry) { + node = got_object_idset_get(graph->node_ids, qid->id); if (node) add_iteration_candidate(graph, node); } blob - 53e8e2331b91afaf0a88bac740b2627340baeca9 blob + cc3271a1acd9dc5061a4f6463843bd81ac04b7f5 --- lib/object.c +++ lib/object.c @@ -445,27 +445,27 @@ got_object_commit_add_parent(struct got_commit_object const char *id_str) { const struct got_error *err = NULL; - struct got_parent_id *pid; + struct got_object_qid *qid; - pid = calloc(1, sizeof(*pid)); - if (pid == NULL) + qid = calloc(1, sizeof(*qid)); + if (qid == NULL) return got_error_from_errno(); - pid->id = calloc(1, sizeof(*pid->id)); - if (pid->id == NULL) { + qid->id = calloc(1, sizeof(*qid->id)); + if (qid->id == NULL) { err = got_error_from_errno(); - free(pid); + free(qid); return err; } - if (!got_parse_sha1_digest(pid->id->sha1, id_str)) { + if (!got_parse_sha1_digest(qid->id->sha1, id_str)) { err = got_error(GOT_ERR_BAD_OBJ_DATA); - free(pid->id); - free(pid); + free(qid->id); + free(qid); return err; } - SIMPLEQ_INSERT_TAIL(&commit->parent_ids, pid, entry); + SIMPLEQ_INSERT_TAIL(&commit->parent_ids, qid, entry); commit->nparents++; return NULL; @@ -917,13 +917,13 @@ got_object_commit_open(struct got_commit_object **comm void got_object_commit_close(struct got_commit_object *commit) { - struct got_parent_id *pid; + struct got_object_qid *qid; while (!SIMPLEQ_EMPTY(&commit->parent_ids)) { - pid = SIMPLEQ_FIRST(&commit->parent_ids); + qid = SIMPLEQ_FIRST(&commit->parent_ids); SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry); - free(pid->id); - free(pid); + free(qid->id); + free(qid); } free(commit->tree_id); blob - 847fbc1f20660a9365bef08597189384661bab96 blob + 1c18f16672018cc1aea650967e5b3d848968f948 --- lib/privsep.c +++ lib/privsep.c @@ -262,7 +262,7 @@ got_privsep_send_commit(struct imsgbuf *ibuf, struct g struct got_imsg_commit_object icommit; uint8_t *buf; size_t len, total; - struct got_parent_id *pid; + struct got_object_qid *qid; memcpy(icommit.tree_id, commit->tree_id->sha1, sizeof(icommit.tree_id)); icommit.author_len = strlen(commit->author); @@ -299,8 +299,8 @@ got_privsep_send_commit(struct imsgbuf *ibuf, struct g len += icommit.committer_tzoff_len; memcpy(buf + len, commit->logmsg, icommit.logmsg_len); len += icommit.logmsg_len; - SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) { - memcpy(buf + len, pid->id, SHA1_DIGEST_LENGTH); + SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + memcpy(buf + len, qid->id, SHA1_DIGEST_LENGTH); len += SHA1_DIGEST_LENGTH; } @@ -470,23 +470,23 @@ got_privsep_recv_commit(struct got_commit_object **com len += icommit.logmsg_len; for (i = 0; i < icommit.nparents; i++) { - struct got_parent_id *pid; + struct got_object_qid *qid; - pid = calloc(1, sizeof(*pid)); - if (pid == NULL) { + qid = calloc(1, sizeof(*qid)); + if (qid == NULL) { err = got_error_from_errno(); break; } - pid->id = calloc(1, sizeof(*pid->id)); - if (pid->id == NULL) { + qid->id = calloc(1, sizeof(*qid->id)); + if (qid->id == NULL) { err = got_error_from_errno(); - free(pid); + free(qid); break; } - memcpy(pid->id, data + len + i * SHA1_DIGEST_LENGTH, - sizeof(*pid->id)); - SIMPLEQ_INSERT_TAIL(&(*commit)->parent_ids, pid, entry); + memcpy(qid->id, data + len + i * SHA1_DIGEST_LENGTH, + sizeof(*qid->id)); + SIMPLEQ_INSERT_TAIL(&(*commit)->parent_ids, qid, entry); (*commit)->nparents++; } break; blob - 6c9a268b1c6ce21ed2cc089da6a3914ec9103d33 blob + 021825fe4d8904f208dbf850b19b6cf4ec8e8d9d --- regress/repository/repository_test.c +++ regress/repository/repository_test.c @@ -63,12 +63,12 @@ static const struct got_error * print_parent_commits(struct got_commit_object *commit, struct got_repository *repo) { - struct got_parent_id *pid; + struct got_object_qid *qid; const struct got_error *err = NULL; struct got_object *obj; - SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) { - err = got_object_open(&obj, repo, pid->id); + SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + err = got_object_open(&obj, repo, qid->id); if (err != NULL) return err; if (got_object_get_type(obj) != GOT_OBJ_TYPE_COMMIT) @@ -146,7 +146,7 @@ static const struct got_error * print_commit_object(struct got_object *obj, struct got_repository *repo) { struct got_commit_object *commit; - struct got_parent_id *pid; + struct got_object_qid *qid; char *buf; const struct got_error *err; struct got_object* treeobj; @@ -161,8 +161,8 @@ print_commit_object(struct got_object *obj, struct got test_printf("tree: %s\n", buf); free(buf); test_printf("parent%s: ", (commit->nparents == 1) ? "" : "s"); - SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) { - err = got_object_id_str(&buf, pid->id); + SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) { + err = got_object_id_str(&buf, qid->id); if (err) return err; test_printf("%s\n", buf); blob - 496fa2a76631969be4f16551d4d26d12f362c19b blob + f20a7b76e08833632a4654100261093ffbb7edaa --- tog/tog.c +++ tog/tog.c @@ -311,15 +311,15 @@ fetch_parent_commit(struct commit_queue_entry **pentry struct got_object *obj = NULL; struct got_commit_object *commit; struct got_object_id *id; - struct got_parent_id *pid; + struct got_object_qid *qid; *pentry = NULL; /* Follow the first parent (TODO: handle merge commits). */ - pid = SIMPLEQ_FIRST(&entry->commit->parent_ids); - if (pid == NULL) + qid = SIMPLEQ_FIRST(&entry->commit->parent_ids); + if (qid == NULL) return NULL; - err = got_object_open(&obj, repo, pid->id); + err = got_object_open(&obj, repo, qid->id); if (err) return err; if (got_object_get_type(obj) != GOT_OBJ_TYPE_COMMIT) { @@ -333,7 +333,7 @@ fetch_parent_commit(struct commit_queue_entry **pentry if (err) return err; - id = got_object_id_dup(pid->id); + id = got_object_id_dup(qid->id); if (id == NULL) { err = got_error_from_errno(); got_object_commit_close(commit);