rename got_parent_id to got_object_qid; better generic name
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
diff --git a/got/got.c b/got/got.c
index e89b380..a4853d1 100644
--- a/got/got.c
+++ b/got/got.c
@@ -265,7 +265,7 @@ print_patch(struct got_commit_object *commit, struct got_object_id *id,
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 got_object_id *id,
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 got_object_id *id,
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);
diff --git a/include/got_object.h b/include/got_object.h
index 9eb68be..a364520 100644
--- a/include/got_object.h
+++ b/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 */
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 53c0fcf..5fb439c 100644
--- a/lib/commit_graph.c
+++ b/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, void *arg)
{
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 *graph,
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 *graph,
}
/* 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);
}
diff --git a/lib/object.c b/lib/object.c
index 53e8e23..cc3271a 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -445,27 +445,27 @@ got_object_commit_add_parent(struct got_commit_object *commit,
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 **commit,
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);
diff --git a/lib/privsep.c b/lib/privsep.c
index 847fbc1..1c18f16 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -262,7 +262,7 @@ got_privsep_send_commit(struct imsgbuf *ibuf, struct got_commit_object *commit)
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 got_commit_object *commit)
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 **commit, struct imsgbuf *ibuf)
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;
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index 6c9a268..021825f 100644
--- a/regress/repository/repository_test.c
+++ b/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_repository *repo)
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);
diff --git a/tog/tog.c b/tog/tog.c
index 496fa2a..f20a7b7 100644
--- a/tog/tog.c
+++ b/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);