untie cancel callback declaration from the work tree
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
diff --git a/got/got.c b/got/got.c
index 86376ee..1242a08 100644
--- a/got/got.c
+++ b/got/got.c
@@ -41,6 +41,7 @@
#include "got_reference.h"
#include "got_repository.h"
#include "got_path.h"
+#include "got_cancel.h"
#include "got_worktree.h"
#include "got_diff.h"
#include "got_commit_graph.h"
diff --git a/include/got_cancel.h b/include/got_cancel.h
new file mode 100644
index 0000000..feffaf3
--- /dev/null
+++ b/include/got_cancel.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2019 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.
+ */
+
+/*
+ * A callback function which is invoked at cancellation points.
+ * May return GOT_ERR_CANCELLED to abort the runing operation.
+ */
+typedef const struct got_error *(*got_cancel_cb)(void *);
diff --git a/include/got_worktree.h b/include/got_worktree.h
index 1a7f2a2..1bd4eff 100644
--- a/include/got_worktree.h
+++ b/include/got_worktree.h
@@ -102,10 +102,6 @@ const struct got_error *got_worktree_set_base_commit_id(struct got_worktree *,
typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
unsigned char, const char *);
-/* A callback function which is invoked at cancellation points.
- * May return GOT_ERR_CANCELLED to abort the runing operation. */
-typedef const struct got_error *(*got_worktree_cancel_cb)(void *);
-
/*
* Attempt to check out files into a work tree from its associated repository
* and path prefix, and update the work tree's file index accordingly.
@@ -128,14 +124,14 @@ typedef const struct got_error *(*got_worktree_cancel_cb)(void *);
*/
const struct got_error *got_worktree_checkout_files(struct got_worktree *,
struct got_pathlist_head *, struct got_repository *,
- got_worktree_checkout_cb, void *, got_worktree_cancel_cb, void *);
+ got_worktree_checkout_cb, void *, got_cancel_cb, void *);
/* Merge the differences between two commits into a work tree. */
const struct got_error *
got_worktree_merge_files(struct got_worktree *,
struct got_object_id *, struct got_object_id *,
struct got_repository *, got_worktree_checkout_cb, void *,
- got_worktree_cancel_cb, void *);
+ got_cancel_cb, void *);
/* A callback function which is invoked to report a path's status. */
typedef const struct got_error *(*got_worktree_status_cb)(void *,
@@ -149,7 +145,7 @@ typedef const struct got_error *(*got_worktree_status_cb)(void *,
*/
const struct got_error *got_worktree_status(struct got_worktree *,
struct got_pathlist_head *, struct got_repository *,
- got_worktree_status_cb, void *, got_worktree_cancel_cb cancel_cb, void *);
+ got_worktree_status_cb, void *, got_cancel_cb cancel_cb, void *);
/*
* Try to resolve a user-provided path to an on-disk path in the work tree.
@@ -265,7 +261,7 @@ const struct got_error *got_worktree_rebase_in_progress(int *,
const struct got_error *got_worktree_rebase_merge_files(
struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
struct got_object_id *, struct got_object_id *, struct got_repository *,
- got_worktree_checkout_cb, void *, got_worktree_cancel_cb, void *);
+ got_worktree_checkout_cb, void *, got_cancel_cb, void *);
/*
* Commit changes merged by got_worktree_rebase_merge_files() to a temporary
@@ -338,7 +334,7 @@ const struct got_error *got_worktree_histedit_in_progress(int *,
const struct got_error *got_worktree_histedit_merge_files(
struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
struct got_object_id *, struct got_object_id *, struct got_repository *,
- got_worktree_checkout_cb, void *, got_worktree_cancel_cb, void *);
+ got_worktree_checkout_cb, void *, got_cancel_cb, void *);
/*
* Commit changes merged by got_worktree_histedit_merge_files() to a temporary
diff --git a/lib/repository.c b/lib/repository.c
index 2937089..6b47a6c 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -41,6 +41,7 @@
#include "got_reference.h"
#include "got_repository.h"
#include "got_path.h"
+#include "got_cancel.h"
#include "got_worktree.h"
#include "got_object.h"
diff --git a/lib/worktree.c b/lib/worktree.c
index 715b19e..30b65e9 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -39,6 +39,7 @@
#include "got_reference.h"
#include "got_object.h"
#include "got_path.h"
+#include "got_cancel.h"
#include "got_worktree.h"
#include "got_opentemp.h"
#include "got_diff.h"
@@ -1386,7 +1387,7 @@ struct diff_cb_arg {
struct got_repository *repo;
got_worktree_checkout_cb progress_cb;
void *progress_arg;
- got_worktree_cancel_cb cancel_cb;
+ got_cancel_cb cancel_cb;
void *cancel_arg;
};
@@ -1782,7 +1783,7 @@ static const struct got_error *
checkout_files(struct got_worktree *worktree, struct got_fileindex *fileindex,
const char *relpath, struct got_object_id *tree_id, const char *entry_name,
struct got_repository *repo, got_worktree_checkout_cb progress_cb,
- void *progress_arg, got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ void *progress_arg, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
struct got_commit_object *commit = NULL;
@@ -1833,7 +1834,7 @@ const struct got_error *
got_worktree_checkout_files(struct got_worktree *worktree,
struct got_pathlist_head *paths, struct got_repository *repo,
got_worktree_checkout_cb progress_cb, void *progress_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL, *sync_err, *unlockerr;
struct got_commit_object *commit = NULL;
@@ -1946,7 +1947,7 @@ struct merge_file_cb_arg {
struct got_fileindex *fileindex;
got_worktree_checkout_cb progress_cb;
void *progress_arg;
- got_worktree_cancel_cb cancel_cb;
+ got_cancel_cb cancel_cb;
void *cancel_arg;
struct got_object_id *commit_id2;
};
@@ -2141,7 +2142,7 @@ merge_files(struct got_worktree *worktree, struct got_fileindex *fileindex,
const char *fileindex_path, struct got_object_id *commit_id1,
struct got_object_id *commit_id2, struct got_repository *repo,
got_worktree_checkout_cb progress_cb, void *progress_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL, *sync_err;
struct got_object_id *tree_id1 = NULL, *tree_id2 = NULL;
@@ -2191,7 +2192,7 @@ const struct got_error *
got_worktree_merge_files(struct got_worktree *worktree,
struct got_object_id *commit_id1, struct got_object_id *commit_id2,
struct got_repository *repo, got_worktree_checkout_cb progress_cb,
- void *progress_arg, got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ void *progress_arg, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err, *unlockerr;
char *fileindex_path = NULL;
@@ -2233,7 +2234,7 @@ struct diff_dir_cb_arg {
struct got_repository *repo;
got_worktree_status_cb status_cb;
void *status_arg;
- got_worktree_cancel_cb cancel_cb;
+ got_cancel_cb cancel_cb;
void *cancel_arg;
/* A pathlist containing per-directory pathlists of ignore patterns. */
struct got_pathlist_head ignores;
@@ -2521,7 +2522,7 @@ static const struct got_error *
worktree_status(struct got_worktree *worktree, const char *path,
struct got_fileindex *fileindex, struct got_repository *repo,
got_worktree_status_cb status_cb, void *status_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
DIR *workdir = NULL;
@@ -2571,7 +2572,7 @@ const struct got_error *
got_worktree_status(struct got_worktree *worktree,
struct got_pathlist_head *paths, struct got_repository *repo,
got_worktree_status_cb status_cb, void *status_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
char *fileindex_path = NULL;
@@ -4666,7 +4667,7 @@ rebase_merge_files(struct got_pathlist_head *merged_paths,
struct got_fileindex *fileindex, struct got_object_id *parent_commit_id,
struct got_object_id *commit_id, struct got_repository *repo,
got_worktree_checkout_cb progress_cb, void *progress_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err;
struct got_reference *commit_ref = NULL;
@@ -4696,7 +4697,7 @@ got_worktree_rebase_merge_files(struct got_pathlist_head *merged_paths,
struct got_object_id *parent_commit_id, struct got_object_id *commit_id,
struct got_repository *repo,
got_worktree_checkout_cb progress_cb, void *progress_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err;
char *commit_ref_name;
@@ -4723,7 +4724,7 @@ got_worktree_histedit_merge_files(struct got_pathlist_head *merged_paths,
struct got_object_id *parent_commit_id, struct got_object_id *commit_id,
struct got_repository *repo,
got_worktree_checkout_cb progress_cb, void *progress_arg,
- got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+ got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err;
char *commit_ref_name;
diff --git a/tog/tog.c b/tog/tog.c
index d1997e2..c92a4d0 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -50,6 +50,7 @@
#include "got_blame.h"
#include "got_privsep.h"
#include "got_path.h"
+#include "got_cancel.h"
#include "got_worktree.h"
#ifndef MIN