commit - b0e2201a54841b5f3d126ad050126fcbd6529fcc
commit + 883f04699494bd53a6d4ddf6e53bd3156429b622
blob - df0f4ad3be5ed31bf13f8da8ca88aef61e9c0a7c
blob + 52bd46fe2b3ac6189e515513a49f08371cabec86
--- include/got_object.h
+++ include/got_object.h
struct got_object_id;
struct got_blob_object;
+struct got_tree_object;
struct got_tree_entry {
SIMPLEQ_ENTRY(got_tree_entry) entry;
struct got_object_id *id;
};
-struct got_tree_object {
- int nentries;
- SIMPLEQ_HEAD(, got_tree_entry) entries;
+SIMPLEQ_HEAD(got_tree_entries_queue, got_tree_entry);
- int refcnt; /* for internal use only */
+struct got_tree_entries {
+ int nentries;
+ struct got_tree_entries_queue head;
};
struct got_object_qid {
/* Dispose of a tree object. */
void got_object_tree_close(struct got_tree_object *);
+/* Get the entries of a tree object. */
+const struct got_tree_entries *got_object_tree_get_entries(
+ struct got_tree_object *);
+
/*
* Attempt to open a blob object in a repository.
* The provided object must be of type GOT_OBJ_TYPE_BLOB.
blob - e4f7dbb99d52e456c8c1133c3467a5c9f4956ea3
blob + abdee829510822e65a88b390d5b9f2bddb49d525
--- lib/diff.c
+++ lib/diff.c
match_entry_by_name(struct got_tree_entry *te1, struct got_tree_object *tree2)
{
struct got_tree_entry *te2;
+ const struct got_tree_entries *entries2;
- SIMPLEQ_FOREACH(te2, &tree2->entries, entry) {
+ entries2 = got_object_tree_get_entries(tree2);
+ SIMPLEQ_FOREACH(te2, &entries2->head, entry) {
if (strcmp(te1->name, te2->name) == 0)
return te2;
}
struct got_tree_entry *te1 = NULL;
struct got_tree_entry *te2 = NULL;
- if (tree1)
- te1 = SIMPLEQ_FIRST(&tree1->entries);
- if (tree2)
- te2 = SIMPLEQ_FIRST(&tree2->entries);
+ if (tree1) {
+ const struct got_tree_entries *entries;
+ entries = got_object_tree_get_entries(tree1);
+ te1 = SIMPLEQ_FIRST(&entries->head);
+ }
+ if (tree2) {
+ const struct got_tree_entries *entries;
+ entries = got_object_tree_get_entries(tree2);
+ te2 = SIMPLEQ_FIRST(&entries->head);
+ }
do {
if (te1) {
blob - ed4dac1b48bc84f3f2eae84ae0ab8cdfaeee3c59
blob + 9f5b22cf0abb36a3fb3306bb8dfc1a43adec26f3
--- lib/got_lib_object.h
+++ lib/got_lib_object.h
int refcnt; /* > 0 if open and/or cached */
};
+struct got_tree_object {
+ struct got_tree_entries entries;
+ int refcnt;
+};
+
struct got_blob_object {
FILE *f;
struct got_zstream_buf zb;
blob - 3a8d465dfe9f909648697939e5bc8b3846ac1fbe
blob + a55e09d2bb2813248ba66fd654251513c7aee429
--- lib/object.c
+++ lib/object.c
if (*tree == NULL)
return got_error_from_errno();
- SIMPLEQ_INIT(&(*tree)->entries);
+ SIMPLEQ_INIT(&(*tree)->entries.head);
while (remain > 0) {
struct got_tree_entry *te;
err = parse_tree_entry(&te, &elen, buf, remain);
if (err)
return err;
- (*tree)->nentries++;
- SIMPLEQ_INSERT_TAIL(&(*tree)->entries, te, entry);
+ (*tree)->entries.nentries++;
+ SIMPLEQ_INSERT_TAIL(&(*tree)->entries.head, te, entry);
buf += elen;
remain -= elen;
}
return;
}
- while (!SIMPLEQ_EMPTY(&tree->entries)) {
- te = SIMPLEQ_FIRST(&tree->entries);
- SIMPLEQ_REMOVE_HEAD(&tree->entries, entry);
+ while (!SIMPLEQ_EMPTY(&tree->entries.head)) {
+ te = SIMPLEQ_FIRST(&tree->entries.head);
+ SIMPLEQ_REMOVE_HEAD(&tree->entries.head, entry);
tree_entry_close(te);
}
free(tree);
}
+const struct got_tree_entries *
+got_object_tree_get_entries(struct got_tree_object *tree)
+{
+ return &tree->entries;
+}
+
static const struct got_error *
read_blob_object_privsep_child(int outfd, int infd, int imsg_fds[2])
{
{
struct got_tree_entry *te;
- SIMPLEQ_FOREACH(te, &tree->entries, entry) {
+ SIMPLEQ_FOREACH(te, &tree->entries.head, entry) {
if (strcmp(te->name, name) == 0)
return te;
}
blob - 2fc13c0bc4f4adfde459767488c025425b5a05fe
blob + a0f4d62e2af51c7ee2dbc2004b2b0dfabd11df26
--- lib/privsep.c
+++ lib/privsep.c
struct got_imsg_tree_object itree;
struct got_tree_entry *te;
- itree.nentries = tree->nentries;
+ itree.nentries = tree->entries.nentries;
if (imsg_compose(ibuf, GOT_IMSG_TREE, 0, 0, -1, &itree, sizeof(itree))
== -1)
return got_error_from_errno();
if (err)
return err;
- SIMPLEQ_FOREACH(te, &tree->entries, entry) {
+ SIMPLEQ_FOREACH(te, &tree->entries.head, entry) {
struct got_imsg_tree_entry ite;
uint8_t *buf = NULL;
size_t len = sizeof(ite) + strlen(te->name);
n = imsg_get(ibuf, &imsg);
if (n == 0) {
- if (*tree && (*tree)->nentries != nentries)
+ if (*tree && (*tree)->entries.nentries != nentries)
goto get_more;
break;
}
err = got_error_from_errno();
break;
}
- (*tree)->nentries = itree.nentries;
- SIMPLEQ_INIT(&(*tree)->entries);
+ (*tree)->entries.nentries = itree.nentries;
+ SIMPLEQ_INIT(&(*tree)->entries.head);
break;
case GOT_IMSG_TREE_ENTRY:
/* This message should be preceeded by GOT_IMSG_TREE. */
memcpy(te->id->sha1, ite.id, SHA1_DIGEST_LENGTH);
te->mode = ite.mode;
- SIMPLEQ_INSERT_TAIL(&(*tree)->entries, te, entry);
+ SIMPLEQ_INSERT_TAIL(&(*tree)->entries.head, te, entry);
nentries++;
break;
default:
imsg_free(&imsg);
}
done:
- if (*tree && (*tree)->nentries != nentries) {
+ if (*tree && (*tree)->entries.nentries != nentries) {
if (err == NULL)
err = got_error(GOT_ERR_PRIVSEP_LEN);
got_object_tree_close(*tree);
blob - 176d82f3d2de6c76d2ed803b1e3c8857aa627a9d
blob + dc82efb90529cd31db50160dcc23a2ef55132cb9
--- lib/worktree.c
+++ lib/worktree.c
got_worktree_checkout_cb progress_cb, void *progress_arg)
{
const struct got_error *err = NULL;
+ const struct got_tree_entries *entries;
struct got_tree_entry *te;
size_t len;
if (strncmp(path, worktree->path_prefix, len) != 0)
return NULL;
- SIMPLEQ_FOREACH(te, &tree->entries, entry) {
+ entries = got_object_tree_get_entries(tree);
+ SIMPLEQ_FOREACH(te, &entries->head, entry) {
err = tree_checkout_entry(worktree, fileindex, te, path, repo,
progress_cb, progress_arg);
if (err)
blob - 021825fe4d8904f208dbf850b19b6cf4ec8e8d9d
blob + 8b5fcb740be61c3312fcb4ccff3900cb9df69a77
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
struct got_repository *repo)
{
struct got_tree_object *tree;
+ const struct got_tree_entries *entries;
struct got_tree_entry *te;
const struct got_error *err;
if (err != NULL)
return err;
- SIMPLEQ_FOREACH(te, &tree->entries, entry) {
+ entries = got_object_tree_get_entries(tree);
+ SIMPLEQ_FOREACH(te, &entries->head, entry) {
struct got_object *treeobj;
char *next_parent;
char *hex;