parse commit objects
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
diff --git a/include/got_error.h b/include/got_error.h
index 3250730..ae0f386 100644
--- a/include/got_error.h
+++ b/include/got_error.h
@@ -26,6 +26,8 @@
#define GOT_ERR_DECOMPRESSION 0x0008
#define GOT_ERR_NO_SPACE 0x0009
#define GOT_ERR_BAD_OBJ_HDR 0x0010
+#define GOT_ERR_OBJ_TYPE 0x0011
+#define GOT_ERR_BAD_OBJ_DATA 0x0012
static const struct got_error {
int code;
@@ -42,6 +44,8 @@ static const struct got_error {
{ GOT_ERR_DECOMPRESSION,"decompression failed" },
{ GOT_ERR_NO_SPACE, "buffer too small" },
{ GOT_ERR_BAD_OBJ_HDR, "bad object header" },
+ { GOT_ERR_OBJ_TYPE, "wrong type of object" },
+ { GOT_ERR_BAD_OBJ_DATA, "bad object data" },
};
const struct got_error * got_error(int code);
diff --git a/include/got_object.h b/include/got_object.h
index e0280c7..dda5b9e 100644
--- a/include/got_object.h
+++ b/include/got_object.h
@@ -18,14 +18,44 @@ struct got_object_id {
u_int8_t sha1[SHA1_DIGEST_LENGTH];
};
+struct got_blob_object {
+ char *dummy;
+};
+
+struct got_tree_object {
+ char *dummy;
+};
+
+struct got_parent_id {
+ SIMPLEQ_ENTRY(got_parent_id) entry;
+ struct got_object_id id;
+};
+
+SIMPLEQ_HEAD(got_parent_id_list, got_parent_id);
+
+struct got_commit_object {
+ struct got_object_id tree_id;
+ unsigned int nparents;
+ SIMPLEQ_HEAD(, got_parent_id) parent_ids;
+ char *author;
+ char *committer;
+ char *logmsg;
+};
+
struct got_object {
int type;
#define GOT_OBJ_TYPE_COMMIT 1
#define GOT_OBJ_TYPE_TREE 2
#define GOT_OBJ_TYPE_BLOB 3
+ size_t hdrlen;
size_t size;
struct got_object_id id;
+ union {
+ struct got_blob_object blob;
+ struct got_tree_object tree;
+ struct got_commit_object commit;
+ } obj;
};
struct got_repository;
@@ -34,3 +64,7 @@ const char * got_object_id_str(struct got_object_id *, char *, size_t);
const struct got_error *got_object_open(struct got_object **,
struct got_repository *, struct got_object_id *);
void got_object_close(struct got_object *);
+const struct got_error *got_object_commit_open(struct got_commit_object **,
+ struct got_repository *, struct got_object *);
+void got_object_commit_close(struct got_commit_object *);
+
diff --git a/include/got_sha1.h b/include/got_sha1.h
new file mode 100644
index 0000000..668013d
--- /dev/null
+++ b/include/got_sha1.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2017 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+int got_parse_sha1_digest(uint8_t *, const char *);
diff --git a/lib/object.c b/lib/object.c
index 254d635..f24b83d 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/queue.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,6 +27,7 @@
#include "got_error.h"
#include "got_object.h"
#include "got_repository.h"
+#include "got_sha1.h"
#ifndef MIN
#define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
@@ -38,6 +41,11 @@
#define GOT_OBJ_TAG_TREE "tree"
#define GOT_OBJ_TAG_BLOB "blob"
+#define GOT_COMMIT_TAG_TREE "tree "
+#define GOT_COMMIT_TAG_PARENT "parent "
+#define GOT_COMMIT_TAG_AUTHOR "author "
+#define GOT_COMMIT_TAG_COMMITTER "committer "
+
const char *
got_object_id_str(struct got_object_id *id, char *buf, size_t size)
{
@@ -148,7 +156,7 @@ inflate_read(struct got_zstream_buf *zb, FILE *f, size_t *outlenp)
}
static const struct got_error *
-parse_obj_header(struct got_object **obj, char *buf, size_t len)
+parse_object_header(struct got_object **obj, char *buf, size_t len)
{
const char *obj_tags[] = {
GOT_OBJ_TAG_COMMIT,
@@ -161,13 +169,15 @@ parse_obj_header(struct got_object **obj, char *buf, size_t len)
GOT_OBJ_TYPE_BLOB,
};
int type = 0;
- size_t size = 0;
+ size_t size = 0, hdrlen = 0;
int i;
char *p = strchr(buf, '\0');
if (p == NULL)
return got_error(GOT_ERR_BAD_OBJ_HDR);
+ hdrlen = strlen(buf) + 1 /* '\0' */;
+
for (i = 0; i < nitems(obj_tags); i++) {
const char *tag = obj_tags[i];
size_t tlen = strlen(tag);
@@ -190,6 +200,7 @@ parse_obj_header(struct got_object **obj, char *buf, size_t len)
*obj = calloc(1, sizeof(**obj));
(*obj)->type = type;
+ (*obj)->hdrlen = hdrlen;
(*obj)->size = size;
return NULL;
}
@@ -201,7 +212,6 @@ read_object_header(struct got_object **obj, struct got_repository *repo,
const struct got_error *err;
FILE *f;
struct got_zstream_buf zb;
- char *p;
size_t outlen;
int i, ret;
@@ -219,40 +229,50 @@ read_object_header(struct got_object **obj, struct got_repository *repo,
if (err)
goto done;
- err = parse_obj_header(obj, zb.outbuf, outlen);
+ err = parse_object_header(obj, zb.outbuf, outlen);
done:
inflate_end(&zb);
fclose(f);
return err;
}
-const struct got_error *
-got_object_open(struct got_object **obj, struct got_repository *repo,
- struct got_object_id *id)
+static const struct got_error *
+object_path(char **path, struct got_object_id *id,
+ struct got_repository *repo)
{
const struct got_error *err = NULL;
- char *path_objects = got_repo_get_path_objects(repo);
char hex[SHA1_DIGEST_STRING_LENGTH];
- char *path = NULL;
+ char *path_objects = got_repo_get_path_objects(repo);
if (path_objects == NULL)
return got_error(GOT_ERR_NO_MEM);
got_object_id_str(id, hex, sizeof(hex));
- if (asprintf(&path, "%s/%.2x/%s",
- path_objects, id->sha1[0], hex + 2) == -1) {
+ if (asprintf(path, "%s/%.2x/%s", path_objects,
+ id->sha1[0], hex + 2) == -1)
err = got_error(GOT_ERR_NO_MEM);
- goto done;
- }
+
+ free(path_objects);
+ return err;
+}
+
+const struct got_error *
+got_object_open(struct got_object **obj, struct got_repository *repo,
+ struct got_object_id *id)
+{
+ const struct got_error *err = NULL;
+ char *path = NULL;
+
+ err = object_path(&path, id, repo);
+ if (err)
+ return err;
err = read_object_header(obj, repo, path);
if (err == NULL)
memcpy((*obj)->id.sha1, id->sha1, SHA1_DIGEST_LENGTH);
-
done:
free(path);
- free(path_objects);
return err;
}
@@ -261,3 +281,214 @@ got_object_close(struct got_object *obj)
{
free(obj);
}
+
+static int
+commit_object_valid(struct got_commit_object *commit)
+{
+ int i;
+ int n;
+
+ if (commit == NULL)
+ return 0;
+
+ n = 0;
+ for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
+ if (commit->tree_id.sha1[i] == 0)
+ n++;
+ }
+ if (n == SHA1_DIGEST_LENGTH)
+ return 0;
+
+ return 1;
+}
+
+static const struct got_error *
+parse_commit_object(struct got_commit_object **commit, char *buf, size_t len)
+{
+ const struct got_error *err = NULL;
+ char *s = buf;
+ size_t tlen;
+ ssize_t remain = (ssize_t)len;
+
+ *commit = calloc(1, sizeof(**commit));
+ if (*commit == NULL)
+ return got_error(GOT_ERR_NO_MEM);
+
+ SIMPLEQ_INIT(&(*commit)->parent_ids);
+
+ tlen = strlen(GOT_COMMIT_TAG_TREE);
+ if (strncmp(s, GOT_COMMIT_TAG_TREE, tlen) == 0) {
+ remain -= tlen;
+ if (remain < SHA1_DIGEST_STRING_LENGTH) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ s += tlen;
+ if (!got_parse_sha1_digest((*commit)->tree_id.sha1, s)) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ remain -= SHA1_DIGEST_STRING_LENGTH;
+ s += SHA1_DIGEST_STRING_LENGTH;
+ } else {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+
+ tlen = strlen(GOT_COMMIT_TAG_PARENT);
+ while (strncmp(s, GOT_COMMIT_TAG_PARENT, tlen) == 0) {
+ struct got_parent_id *pid;
+
+ remain -= tlen;
+ if (remain < SHA1_DIGEST_STRING_LENGTH) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+
+ pid = calloc(1, sizeof(*pid));
+ if (pid == NULL) {
+ err = got_error(GOT_ERR_NO_MEM);
+ goto done;
+ }
+ s += tlen;
+ if (!got_parse_sha1_digest(pid->id.sha1, s)) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ SIMPLEQ_INSERT_TAIL(&(*commit)->parent_ids, pid, entry);
+ (*commit)->nparents++;
+
+ s += SHA1_DIGEST_STRING_LENGTH;
+ }
+
+ tlen = strlen(GOT_COMMIT_TAG_AUTHOR);
+ if (strncmp(s, GOT_COMMIT_TAG_AUTHOR, tlen) == 0) {
+ char *p;
+
+ remain -= tlen;
+ if (remain <= 0) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ s += tlen;
+ p = strchr(s, '\n');
+ if (p == NULL) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ *p = '\0';
+ (*commit)->author = strdup(s);
+ if ((*commit)->author == NULL) {
+ err = got_error(GOT_ERR_NO_MEM);
+ goto done;
+ }
+ s += strlen((*commit)->author) + 1;
+ }
+
+ tlen = strlen(GOT_COMMIT_TAG_COMMITTER);
+ if (strncmp(s, GOT_COMMIT_TAG_COMMITTER, tlen) == 0) {
+ char *p;
+
+ remain -= tlen;
+ if (remain <= 0) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ s += tlen;
+ p = strchr(s, '\n');
+ if (p == NULL) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+ *p = '\0';
+ (*commit)->committer = strdup(s);
+ if ((*commit)->committer == NULL) {
+ err = got_error(GOT_ERR_NO_MEM);
+ goto done;
+ }
+ s += strlen((*commit)->committer) + 1;
+ }
+
+ (*commit)->logmsg = strdup(s);
+done:
+ if (err)
+ got_object_commit_close(*commit);
+ return err;
+}
+
+static const struct got_error *
+read_commit_object(struct got_commit_object **commit,
+ struct got_repository *repo, struct got_object *obj, const char *path)
+{
+ const struct got_error *err = NULL;
+ FILE *f;
+ struct got_zstream_buf zb;
+ size_t len;
+ char *p;
+ int i, ret;
+
+ f = fopen(path, "rb");
+ if (f == NULL)
+ return got_error(GOT_ERR_BAD_PATH);
+
+ err = inflate_init(&zb, 8192);
+ if (err) {
+ fclose(f);
+ return err;
+ }
+
+ do {
+ err = inflate_read(&zb, f, &len);
+ if (err || len == 0)
+ break;
+ } while (len < obj->hdrlen + obj->size);
+
+ if (len < obj->hdrlen + obj->size) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
+ }
+
+ /* Skip object header. */
+ len -= obj->hdrlen;
+ err = parse_commit_object(commit, zb.outbuf + obj->hdrlen, len);
+done:
+ inflate_end(&zb);
+ fclose(f);
+ return err;
+}
+
+const struct got_error *
+got_object_commit_open(struct got_commit_object **commit,
+ struct got_repository *repo, struct got_object *obj)
+{
+ const struct got_error *err = NULL;
+ char *path = NULL;
+
+ if (obj->type != GOT_OBJ_TYPE_COMMIT)
+ return got_error(GOT_ERR_OBJ_TYPE);
+
+ err = object_path(&path, &obj->id, repo);
+ if (err)
+ return err;
+
+ err = read_commit_object(commit, repo, obj, path);
+ free(path);
+ return err;
+}
+
+void
+got_object_commit_close(struct got_commit_object *commit)
+{
+ struct got_parent_id *pid;
+
+ while (!SIMPLEQ_EMPTY(&commit->parent_ids)) {
+ pid = SIMPLEQ_FIRST(&commit->parent_ids);
+ SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry);
+ free(pid);
+ }
+
+ free(commit->author);
+ free(commit->committer);
+ free(commit->logmsg);
+ free(commit);
+}
diff --git a/lib/refs.c b/lib/refs.c
index 19e8815..b299fd1 100644
--- a/lib/refs.c
+++ b/lib/refs.c
@@ -15,18 +15,19 @@
*/
#include <sys/types.h>
+#include <sys/queue.h>
+
#include <sha1.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <util.h>
-#include <limits.h>
-#include <errno.h>
#include "got_error.h"
#include "got_object.h"
#include "got_repository.h"
#include "got_refs.h"
+#include "got_sha1.h"
#include "path.h"
@@ -58,45 +59,6 @@ parse_symref(struct got_reference **ref, const char *name, const char *line)
return NULL;
}
-static int
-parse_xdigit(uint8_t *val, const char *hex)
-{
- char *ep;
- long lval;
-
- errno = 0;
- lval = strtol(hex, &ep, 16);
- if (hex[0] == '\0' || *ep != '\0')
- return 0;
- if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
- return 0;
-
- *val = (uint8_t)lval;
- return 1;
-}
-
-static int
-parse_sha1_digest(uint8_t *digest, const char *line)
-{
- uint8_t b = 0;
- char hex[3] = {'\0', '\0', '\0'};
- int i, j;
-
- for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
- if (line[0] == '\0' || line[1] == '\0')
- return 0;
- for (j = 0; j < 2; j++) {
- hex[j] = *line;
- line++;
- }
- if (!parse_xdigit(&b, hex))
- return 0;
- digest[i] = b;
- }
-
- return 1;
-}
-
static const struct got_error *
parse_ref_line(struct got_reference **ref, const char *name, const char *line)
{
@@ -112,7 +74,7 @@ parse_ref_line(struct got_reference **ref, const char *name, const char *line)
if (ref_name == NULL)
return got_error(GOT_ERR_NO_MEM);
- if (!parse_sha1_digest(digest, line))
+ if (!got_parse_sha1_digest(digest, line))
return got_error(GOT_ERR_NOT_REF);
*ref = calloc(1, sizeof(**ref));
diff --git a/lib/sha1.c b/lib/sha1.c
new file mode 100644
index 0000000..e6058f8
--- /dev/null
+++ b/lib/sha1.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sha1.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+
+static int
+parse_xdigit(uint8_t *val, const char *hex)
+{
+ char *ep;
+ long lval;
+
+ errno = 0;
+ lval = strtol(hex, &ep, 16);
+ if (hex[0] == '\0' || *ep != '\0')
+ return 0;
+ if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
+ return 0;
+
+ *val = (uint8_t)lval;
+ return 1;
+}
+
+int
+got_parse_sha1_digest(uint8_t *digest, const char *line)
+{
+ uint8_t b = 0;
+ char hex[3] = {'\0', '\0', '\0'};
+ int i, j;
+
+ for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
+ if (line[0] == '\0' || line[1] == '\0')
+ return 0;
+ for (j = 0; j < 2; j++) {
+ hex[j] = *line;
+ line++;
+ }
+ if (!parse_xdigit(&b, hex))
+ return 0;
+ digest[i] = b;
+ }
+
+ return 1;
+}
diff --git a/regress/repository/Makefile b/regress/repository/Makefile
index 091f43b..de7eb21 100644
--- a/regress/repository/Makefile
+++ b/regress/repository/Makefile
@@ -1,7 +1,7 @@
.PATH:${.CURDIR}/../../lib
PROG = repository_test
-SRCS = path.c repository.c error.c refs.c object.c repository_test.c
+SRCS = path.c repository.c error.c refs.c object.c sha1.c repository_test.c
CPPFLAGS = -I${.CURDIR}/../../include
LDADD = -lutil -lz
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index aeb8b92..4545189 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/queue.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <sha1.h>
@@ -53,6 +55,24 @@ repo_read_object_header(const char *repo_path)
if (err != NULL || obj == NULL)
return 0;
printf("object type=%d size=%lu\n", obj->type, obj->size);
+ if (obj->type == GOT_OBJ_TYPE_COMMIT) {
+ struct got_commit_object *commit;
+ struct got_parent_id *pid;
+
+ err = got_object_commit_open(&commit, repo, obj);
+ if (err != NULL || commit == NULL)
+ return 0;
+ printf("tree: %s\n",
+ got_object_id_str(&commit->tree_id, buf, sizeof(buf)));
+ printf("parent%s: ", (commit->nparents == 1) ? "" : "s");
+ SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) {
+ printf("%s\n",
+ got_object_id_str(&pid->id, buf, sizeof(buf)));
+ }
+ printf("author: %s\n", commit->author);
+ printf("committer: %s\n", commit->committer);
+ printf("log: %s\n", commit->logmsg);
+ }
got_object_close(obj);
free(id);
got_ref_close(head_ref);