commit - e620954619292de6ad76df32021946b9d6aa168c
commit + 6fb7cd117fc5150498bd6135a2904a7c726ae49e
blob - 1242a086fa287cd6d80a920af5d192decb4eb1b1
blob + 9062a445d85049f837f67d8e1cca4798c73df9e6
--- got/got.c
+++ got/got.c
struct got_object_id *yca_id;
err = got_commit_graph_find_youngest_common_ancestor(&yca_id,
- commit_id, base_commit_id, repo);
+ commit_id, base_commit_id, repo, check_cancelled, NULL);
if (err)
return err;
if (err)
goto done;
- err = got_commit_graph_iter_start(graph, head_commit_id, repo);
+ err = got_commit_graph_iter_start(graph, head_commit_id, repo,
+ check_cancelled, NULL);
if (err)
goto done;
} else if (err->code != GOT_ERR_ITER_NEED_MORE)
break;
err = got_commit_graph_fetch_commits(graph, 1,
- repo);
+ repo, check_cancelled, NULL);
if (err)
break;
}
first_parent_traversal, repo);
if (err)
return err;
- err = got_commit_graph_iter_start(graph, root_id, repo);
+ err = got_commit_graph_iter_start(graph, root_id, repo,
+ check_cancelled, NULL);
if (err)
goto done;
for (;;) {
}
if (err->code != GOT_ERR_ITER_NEED_MORE)
break;
- err = got_commit_graph_fetch_commits(graph, 1, repo);
+ err = got_commit_graph_fetch_commits(graph, 1, repo,
+ check_cancelled, NULL);
if (err)
break;
else
}
bca.repo = repo;
- error = got_blame(in_repo_path, commit_id, repo, blame_cb, &bca);
+ error = got_blame(in_repo_path, commit_id, repo, blame_cb, &bca,
+ check_cancelled, NULL);
if (error)
goto done;
done:
if (err)
return err;
- err = got_commit_graph_iter_start(graph, iter_start_id, repo);
+ err = got_commit_graph_iter_start(graph, iter_start_id, repo,
+ check_cancelled, NULL);
if (err)
goto done;
while (got_object_id_cmp(commit_id, iter_stop_id) != 0) {
goto done;
} else if (err->code != GOT_ERR_ITER_NEED_MORE)
goto done;
- err = got_commit_graph_fetch_commits(graph, 1, repo);
+ err = got_commit_graph_fetch_commits(graph, 1, repo,
+ check_cancelled, NULL);
if (err)
goto done;
} else {
base_commit_id = got_worktree_get_base_commit_id(worktree);
error = got_commit_graph_find_youngest_common_ancestor(&yca_id,
- base_commit_id, branch_head_commit_id, repo);
+ base_commit_id, branch_head_commit_id, repo,
+ check_cancelled, NULL);
if (error)
goto done;
if (yca_id == NULL) {
blob - 9258c77dafa469d8dbc168725c3a4ac31456e981
blob + c4c15ba2906056d4efdd0378fb21aa0e70cf83f7
--- include/got_blame.h
+++ include/got_blame.h
const struct got_error *got_blame(const char *,
struct got_object_id *, struct got_repository *,
const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
- void *);
+ void *, got_cancel_cb, void *);
blob - 3841e17182116b5b527f87c30a553903419e7258
blob + 488763be1b3d599c4353c878a58025622a9cdcc2
--- include/got_commit_graph.h
+++ include/got_commit_graph.h
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 *);
+ 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 *);
+ 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 *);
const struct got_error *got_commit_graph_intersect(struct got_object_id **,
/* Find the youngest common ancestor of two commits. */
const struct got_error *got_commit_graph_find_youngest_common_ancestor(
struct got_object_id **, struct got_object_id *, struct got_object_id *,
- struct got_repository *);
+ struct got_repository *, got_cancel_cb, void *);
blob - 6f7839e4fcde379b6c902d40811dad5dc37c22ab
blob + a602d0a3605f055369bf85a999e52e7399ff2c86
--- lib/blame.c
+++ lib/blame.c
#include "got_error.h"
#include "got_object.h"
+#include "got_cancel.h"
#include "got_blame.h"
+#include "got_commit_graph.h"
#include "got_opentemp.h"
#include "got_lib_inflate.h"
#include "got_lib_delta.h"
#include "got_lib_object.h"
#include "got_lib_diff.h"
-#include "got_commit_graph.h"
struct got_blame_line {
int annotated;
blame_open(struct got_blame **blamep, const char *path,
struct got_object_id *start_commit_id, struct got_repository *repo,
const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
- void *arg)
+ void *arg, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
struct got_object *obj = NULL;
err = got_commit_graph_open(&graph, start_commit_id, path, 1, repo);
if (err)
return err;
- err = got_commit_graph_iter_start(graph, start_commit_id, repo);
+ err = got_commit_graph_iter_start(graph, start_commit_id, repo,
+ cancel_cb, cancel_arg);
if (err)
goto done;
id = start_commit_id;
}
if (err->code != GOT_ERR_ITER_NEED_MORE)
break;
- err = got_commit_graph_fetch_commits(graph, 1, repo);
+ err = got_commit_graph_fetch_commits(graph, 1, repo,
+ cancel_cb, cancel_arg);
if (err)
break;
continue;
got_blame(const char *path, struct got_object_id *commit_id,
struct got_repository *repo,
const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
- void *arg)
+ void *arg, got_cancel_cb cancel_cb, void* cancel_arg)
{
const struct got_error *err = NULL, *close_err = NULL;
struct got_blame *blame;
if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
return got_error_from_errno2("asprintf", path);
- err = blame_open(&blame, abspath, commit_id, repo, cb, arg);
+ err = blame_open(&blame, abspath, commit_id, repo, cb, arg,
+ cancel_cb, cancel_arg);
free(abspath);
if (blame)
close_err = blame_close(blame);
blob - 9b907af2dab638d435d58c69188bb1ce33f7d641
blob + 51eb77382cd5c58ba7622c58006aa44e64287c35
--- lib/commit_graph.c
+++ lib/commit_graph.c
#include "got_error.h"
#include "got_object.h"
+#include "got_cancel.h"
#include "got_commit_graph.h"
#include "got_path.h"
static const struct got_error *
fetch_commits_from_open_branches(int *nfetched,
struct got_object_id **changed_id, struct got_commit_graph *graph,
- struct got_repository *repo)
+ struct got_repository *repo, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err;
struct add_branch_tip_arg arg;
struct got_commit_graph_node *new_node;
int branch_done, changed;
+ if (cancel_cb) {
+ err = (*cancel_cb)(cancel_arg);
+ if (err)
+ break;
+ }
+
commit_id = arg.tips[i].commit_id;
commit = arg.tips[i].commit;
new_node = arg.tips[i].new_node;
const struct got_error *
got_commit_graph_fetch_commits(struct got_commit_graph *graph, int limit,
- struct got_repository *repo)
+ 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);
+ &changed_id, graph, repo, cancel_cb, cancel_arg);
if (err)
return err;
if (ncommits == 0)
const struct got_error *
got_commit_graph_iter_start(struct got_commit_graph *graph,
- struct got_object_id *id, struct got_repository *repo)
+ struct got_object_id *id, struct got_repository *repo,
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
struct got_commit_graph_node *start_node;
while (start_node == NULL) {
int ncommits;
err = fetch_commits_from_open_branches(&ncommits, NULL, graph,
- repo);
+ repo, cancel_cb, cancel_arg);
if (err)
return err;
if (ncommits == 0)
while (changed_id == NULL) {
int ncommits;
err = fetch_commits_from_open_branches(&ncommits,
- &changed_id, graph, repo);
+ &changed_id, graph, repo, cancel_cb, cancel_arg);
if (err) {
got_object_commit_close(commit);
return err;
const struct got_error *
got_commit_graph_find_youngest_common_ancestor(struct got_object_id **yca_id,
struct got_object_id *commit_id, struct got_object_id *commit_id2,
- struct got_repository *repo)
+ struct got_repository *repo, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
struct got_commit_graph *graph = NULL, *graph2 = NULL;
if (err)
goto done;
- err = got_commit_graph_iter_start(graph, commit_id, repo);
+ err = got_commit_graph_iter_start(graph, commit_id, repo,
+ cancel_cb, cancel_arg);
if (err)
goto done;
- err = got_commit_graph_iter_start(graph2, commit_id2, repo);
+ err = got_commit_graph_iter_start(graph2, commit_id2, repo,
+ cancel_cb, cancel_arg);
if (err)
goto done;
for (;;) {
struct got_object_id *id, *id2;
+ if (cancel_cb) {
+ err = (*cancel_cb)(cancel_arg);
+ if (err)
+ break;
+ }
+
if (!completed) {
err = got_commit_graph_iter_next(&id, graph);
if (err) {
else if (err->code != GOT_ERR_ITER_NEED_MORE)
break;
err = got_commit_graph_fetch_commits(graph, 1,
- repo);
+ repo, cancel_cb, cancel_arg);
if (err)
break;
}
else if (err->code != GOT_ERR_ITER_NEED_MORE)
break;
err = got_commit_graph_fetch_commits(graph2, 1,
- repo);
+ repo, cancel_cb, cancel_arg);
if (err)
break;
}
blob - c92a4d04f1ff3d0ed6ae29e308c93512bed28e2e
blob + c8b1e457cb5ed381384f58dd87556998a7825000
--- tog/tog.c
+++ tog/tog.c
#include "got_repository.h"
#include "got_diff.h"
#include "got_opentemp.h"
-#include "got_commit_graph.h"
#include "got_utf8.h"
+#include "got_cancel.h"
+#include "got_commit_graph.h"
#include "got_blame.h"
#include "got_privsep.h"
#include "got_path.h"
-#include "got_cancel.h"
#include "got_worktree.h"
#ifndef MIN
if (err->code != GOT_ERR_ITER_NEED_MORE)
break;
err = got_commit_graph_fetch_commits(graph,
- minqueue, repo);
+ minqueue, repo, NULL, NULL);
if (err)
return err;
continue;
struct tog_log_thread_args *a = arg;
int done = 0;
- err = got_commit_graph_iter_start(a->graph, a->start_id, a->repo);
+ err = got_commit_graph_iter_start(a->graph, a->start_id, a->repo,
+ NULL, NULL);
if (err)
return (void *)err;
int errcode;
err = got_blame(ta->path, a->commit_id, ta->repo,
- blame_cb, ta->cb_args);
+ blame_cb, ta->cb_args, NULL, NULL);
errcode = pthread_mutex_lock(&tog_mutex);
if (errcode)