Commit 917bfd05b82e9f84999cfbb008c9dcefd388f77f

Stefan Sperling 2018-06-10T14:55:20

add an extra callback argument to got_object_idset_for_each()

diff --git a/lib/got_lib_object_idset.h b/lib/got_lib_object_idset.h
index 1c726ce..ce9c832 100644
--- a/lib/got_lib_object_idset.h
+++ b/lib/got_lib_object_idset.h
@@ -27,5 +27,5 @@ const struct got_error *got_object_idset_remove(struct got_object_idset *,
 int got_object_idset_contains(struct got_object_idset *,
     struct got_object_id *);
 void got_object_idset_for_each(struct got_object_idset *,
-    void (*cb)(struct got_object_id *, void *));
+    void (*cb)(struct got_object_id *, void *, void *), void *);
 unsigned int got_object_idset_num_elements(struct got_object_idset *);
diff --git a/lib/object_idset.c b/lib/object_idset.c
index 3487cfb..2fa47df 100644
--- a/lib/object_idset.c
+++ b/lib/object_idset.c
@@ -196,14 +196,14 @@ got_object_idset_contains(struct got_object_idset *set,
 }
 
 void got_object_idset_for_each(struct got_object_idset *set,
-    void (*cb)(struct got_object_id *, void *))
+    void (*cb)(struct got_object_id *, void *, void *), void *arg)
 {
 	struct got_object_idset_element *entry;
 	int i;
 
 	for (i = 0; i < nitems(set->entries); i++) {
 		TAILQ_FOREACH(entry, &set->entries[i], entry)
-			cb(&entry->id, entry->data);
+			cb(&entry->id, entry->data, arg);
 	}
 }
 
diff --git a/regress/idset/idset_test.c b/regress/idset/idset_test.c
index 78476ec..3b62000 100644
--- a/regress/idset/idset_test.c
+++ b/regress/idset/idset_test.c
@@ -56,7 +56,7 @@ static const char *data1 = "data1", *data2 = "data2", *data3 = "data3";
 static int iter_count;
 
 static void
-idset_cb(struct got_object_id *id, void *data) {
+idset_cb(struct got_object_id *id, void *data, void *arg) {
 	if (iter_count == 0 &&
 	    (got_object_id_cmp(id, &id1) != 0 || data != (void *)data1))
 		abort();
@@ -182,7 +182,7 @@ idset_add_remove_iter(void)
 		goto done;
 	}
 
-	got_object_idset_for_each(set, idset_cb);
+	got_object_idset_for_each(set, idset_cb, NULL);
 done:
 	got_object_idset_free(set);
 	return (err == NULL);
diff --git a/tog/Makefile b/tog/Makefile
index cb1a8b9..730e0f0 100644
--- a/tog/Makefile
+++ b/tog/Makefile
@@ -3,7 +3,7 @@
 PROG=		tog
 SRCS=		tog.c delta.c diff.c diffreg.c error.c fileindex.c object.c \
 		opentemp.c path.c pack.c privsep.c reference.c repository.c \
-		sha1.c worktree.c zbuf.c
+		sha1.c worktree.c zbuf.c object_idset.c commit_graph.c
 
 CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib
 LDADD = -lpanel -lncursesw -lutil -lz