commit e620954619292de6ad76df32021946b9d6aa168c from: Stefan Sperling date: Thu Aug 22 09:12:24 2019 UTC untie cancel callback declaration from the work tree commit - d0275cf721b0a74c20c210cf04b585c770e55109 commit + e620954619292de6ad76df32021946b9d6aa168c blob - 86376ee292ee135f052fc9d6e3b2af6794462a1f blob + 1242a086fa287cd6d80a920af5d192decb4eb1b1 --- got/got.c +++ 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" blob - /dev/null blob + feffaf3ce97363f7cedaaba16d6d781e777e2838 (mode 644) --- /dev/null +++ include/got_cancel.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 Stefan Sperling + * + * 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 *); blob - 1a7f2a24bda27f5261331d7f5788b4a0b5ccdf91 blob + 1bd4eff4c92e7c57dc9166775ec5c8efd2916fec --- include/got_worktree.h +++ include/got_worktree.h @@ -102,10 +102,6 @@ const struct got_error *got_worktree_set_base_commit_i 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_ */ 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_ */ 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_progres 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_progr 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 blob - 293708998a14514dfef24428b4aa26e8e2c97ffc blob + 6b47a6ca6cbe47ad06ff20e0a5afee543df08851 --- lib/repository.c +++ 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" blob - 715b19e7c0796c190b6a68be4e36bcb3dde4df4d blob + 30b65e930802c67ccebb4b4023d1ba02f176761e --- lib/worktree.c +++ 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_ 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_pa 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_he 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_ 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; blob - d1997e2a143daa17a6cd975dfdd7f88fbee2773a blob + c92a4d04f1ff3d0ed6ae29e308c93512bed28e2e --- tog/tog.c +++ 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