commit - a85446b211f707066c360f637d4f824f8695828d
commit + ee780d5ce8c335e430804438c35eb48564ec0afb
blob - e658e622b058b0f31f698572b39ed94a026bc154
blob + 9f9906e1f49348ef40c8d4cc7841bc6fbae5a3c7
--- got/got.c
+++ got/got.c
for (;;) {
struct got_object_id *id;
- err = got_commit_graph_iter_next(&id, graph);
+ err = got_commit_graph_iter_next(&id, graph, repo,
+ check_cancelled, NULL);
if (err) {
- if (err->code == GOT_ERR_ITER_COMPLETED) {
+ if (err->code == GOT_ERR_ITER_COMPLETED)
err = NULL;
- break;
- } else if (err->code != GOT_ERR_ITER_NEED_MORE)
- break;
- err = got_commit_graph_fetch_commits(graph, 1,
- repo, check_cancelled, NULL);
- if (err)
- break;
+ break;
}
if (id) {
if (sigint_received || sigpipe_received)
break;
- err = got_commit_graph_iter_next(&id, graph);
+ err = got_commit_graph_iter_next(&id, graph, repo,
+ check_cancelled, NULL);
if (err) {
- if (err->code == GOT_ERR_ITER_COMPLETED) {
+ if (err->code == GOT_ERR_ITER_COMPLETED)
err = NULL;
- break;
- }
- if (err->code != GOT_ERR_ITER_NEED_MORE)
- break;
- err = got_commit_graph_fetch_commits(graph, 1, repo,
- check_cancelled, NULL);
- if (err)
- break;
- else
- continue;
+ break;
}
if (id == NULL)
break;
if (err)
goto done;
while (got_object_id_cmp(commit_id, iter_stop_id) != 0) {
- err = got_commit_graph_iter_next(&parent_id, graph);
+ err = got_commit_graph_iter_next(&parent_id, graph, repo,
+ check_cancelled, NULL);
if (err) {
if (err->code == GOT_ERR_ITER_COMPLETED) {
err = got_error_msg(GOT_ERR_ANCESTRY,
"ran out of commits to rebase before "
"youngest common ancestor commit has "
"been reached?!?");
- goto done;
- } else if (err->code != GOT_ERR_ITER_NEED_MORE)
- goto done;
- err = got_commit_graph_fetch_commits(graph, 1, repo,
- check_cancelled, NULL);
- if (err)
- goto done;
+ }
+ goto done;
} else {
err = check_path_prefix(parent_id, commit_id,
path_prefix, path_prefix_errcode, repo);
blob - 488763be1b3d599c4353c878a58025622a9cdcc2
blob + e21a5301c9f6ed92c32d078f03478d6f8a79423f
--- include/got_commit_graph.h
+++ include/got_commit_graph.h
struct got_repository *repo);
void got_commit_graph_close(struct got_commit_graph *);
-const struct got_error *got_commit_graph_fetch_commits(
- struct got_commit_graph *, int, struct got_repository *,
- got_cancel_cb, void *);
const struct got_error *got_commit_graph_iter_start(
struct got_commit_graph *, struct got_object_id *, struct got_repository *,
got_cancel_cb, void *);
const struct got_error *got_commit_graph_iter_next(struct got_object_id **,
- struct got_commit_graph *);
+ struct got_commit_graph *, struct got_repository *, got_cancel_cb, void *);
const struct got_error *got_commit_graph_intersect(struct got_object_id **,
struct got_commit_graph *, struct got_commit_graph *,
struct got_repository *);
blob - 577bc08aea231c5c5521837f99004a21cfb18a53
blob + b8f22cf154bb9629cdb7274e611319bef1a7031d
--- include/got_error.h
+++ include/got_error.h
#define GOT_ERR_PACK_OFFSET 42
#define GOT_ERR_OBJ_EXISTS 43
#define GOT_ERR_BAD_OBJ_ID 44
-#define GOT_ERR_ITER_NEED_MORE 45
+/* 45 is currently unused */
#define GOT_ERR_ITER_COMPLETED 46
#define GOT_ERR_RANGE 47
#define GOT_ERR_EXPECTED 48 /* for use in regress tests only */
{ GOT_ERR_PACK_OFFSET, "bad offset in pack file" },
{ GOT_ERR_OBJ_EXISTS, "object already exists" },
{ GOT_ERR_BAD_OBJ_ID, "bad object id" },
- { GOT_ERR_ITER_NEED_MORE,"more items needed to continue iteration" },
+ /* 45 is currently unused */
{ GOT_ERR_ITER_COMPLETED,"iteration completed" },
{ GOT_ERR_RANGE, "value out of range" },
{ GOT_ERR_EXPECTED, "expected an error but have no error" },
blob - a21b3cf85babdf6fe5b6c2dcc4ef02419742dfc6
blob + 00b87984bbe853e9f667f29f39ff58191c20ca30
--- lib/blame.c
+++ lib/blame.c
goto done;
id = start_commit_id;
for (;;) {
- err = got_commit_graph_iter_next(&pid, graph);
+ err = got_commit_graph_iter_next(&pid, graph, repo,
+ cancel_cb, cancel_arg);
if (err) {
- if (err->code == GOT_ERR_ITER_COMPLETED) {
+ if (err->code == GOT_ERR_ITER_COMPLETED)
err = NULL;
- break;
- }
- if (err->code != GOT_ERR_ITER_NEED_MORE)
- break;
- err = got_commit_graph_fetch_commits(graph, 1, repo,
- cancel_cb, cancel_arg);
- if (err)
- break;
- continue;
+ break;
}
if (pid) {
err = blame_commit(blame, pid, id, path, repo, cb, arg);
blob - 899ed14bbc2aac2a8d0b0ce342ae94aff600f7ff
blob + c4649f5b6f357fc0bf48d47dad38c58b413f3849
--- lib/commit_graph.c
+++ lib/commit_graph.c
(*nfetched) = arg.ntips;
return err;
}
-
-const struct got_error *
-got_commit_graph_fetch_commits(struct got_commit_graph *graph, int limit,
- struct got_repository *repo, got_cancel_cb cancel_cb, void *cancel_arg)
-{
- const struct got_error *err;
- int nfetched = 0, ncommits;
- struct got_object_id *changed_id = NULL;
- while (nfetched < limit) {
- if (cancel_cb) {
- err = (*cancel_cb)(cancel_arg);
- if (err)
- return err;
- }
- err = fetch_commits_from_open_branches(&ncommits,
- &changed_id, graph, repo, cancel_cb, cancel_arg);
- if (err)
- return err;
- if (ncommits == 0)
- break;
- if (changed_id)
- nfetched += ncommits;
- }
-
- return NULL;
-}
-
static const struct got_error *
free_node_iter(struct got_object_id *id, void *data, void *arg)
{
const struct got_error *
got_commit_graph_iter_next(struct got_object_id **id,
- struct got_commit_graph *graph)
+ struct got_commit_graph *graph, struct got_repository *repo,
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
+ const struct got_error *err = NULL;
+
*id = NULL;
if (graph->iter_node == NULL) {
return NULL;
}
- if (TAILQ_NEXT(graph->iter_node, entry) == NULL)
- return got_error(GOT_ERR_ITER_NEED_MORE);
+ while (TAILQ_NEXT(graph->iter_node, entry) == NULL &&
+ got_object_idset_num_elements(graph->open_branches) > 0) {
+ int ncommits;
+ struct got_object_id *changed_id;
+ err = fetch_commits_from_open_branches(&ncommits,
+ &changed_id, graph, repo, cancel_cb, cancel_arg);
+ if (err)
+ return err;
+ }
*id = &graph->iter_node->id;
graph->iter_node = TAILQ_NEXT(graph->iter_node, entry);
goto done;
for (;;) {
- struct got_object_id *id, *id2;
+ struct got_object_id *id = NULL, *id2 = NULL;
if (cancel_cb) {
err = (*cancel_cb)(cancel_arg);
}
if (!completed) {
- err = got_commit_graph_iter_next(&id, graph);
+ err = got_commit_graph_iter_next(&id, graph, repo,
+ cancel_cb, cancel_arg);
if (err) {
- if (err->code == GOT_ERR_ITER_COMPLETED)
- completed = 1;
- else if (err->code != GOT_ERR_ITER_NEED_MORE)
+ if (err->code != GOT_ERR_ITER_COMPLETED)
break;
- err = got_commit_graph_fetch_commits(graph, 1,
- repo, cancel_cb, cancel_arg);
- if (err)
- break;
+ err = NULL;
+ completed = 1;
}
}
if (!completed2) {
- err = got_commit_graph_iter_next(&id2, graph2);
+ err = got_commit_graph_iter_next(&id2, graph2, repo,
+ cancel_cb, cancel_arg);
if (err) {
- if (err->code == GOT_ERR_ITER_COMPLETED)
- completed2 = 1;
- else if (err->code != GOT_ERR_ITER_NEED_MORE)
+ if (err->code != GOT_ERR_ITER_COMPLETED)
break;
- err = got_commit_graph_fetch_commits(graph2, 1,
- repo, cancel_cb, cancel_arg);
- if (err)
- break;
+ err = NULL;
+ completed2 = 1;
}
}
blob - db28ea842a1df6aae9cb7bf3074ee8528ff61878
blob + 837e0f916a1ff344f792025b8159bb1660fe019e
--- tog/tog.c
+++ tog/tog.c
struct commit_queue_entry *entry;
int errcode;
- err = got_commit_graph_iter_next(&id, graph);
- if (err) {
- if (err->code != GOT_ERR_ITER_NEED_MORE)
- break;
- err = got_commit_graph_fetch_commits(graph,
- minqueue, repo, NULL, NULL);
- if (err)
- return err;
- continue;
- }
-
- if (id == NULL)
+ err = got_commit_graph_iter_next(&id, graph, repo, NULL, NULL);
+ if (err || id == NULL)
break;
err = got_object_open_as_commit(&commit, repo, id);