commit f6b8c3c2253c61e60153121cfa4da7c350787598 from: Stefan Sperling date: Mon Jul 24 12:50:40 2023 UTC fix some non-idiomatic calls of the cancellation callback This callback could return any error code. Do not mask all such errors as cancellation. commit - cdbfe5d2325bd7ae7a197ce5e7a93fcdba9097cb commit + f6b8c3c2253c61e60153121cfa4da7c350787598 blob - 92a65f77687232bb4d27acbaae8e54b80258a589 blob + d4aed4f6bf14dbd91a5d5efb9d4479dcd6164ec4 --- lib/worktree.c +++ lib/worktree.c @@ -2273,10 +2273,14 @@ static const struct got_error * diff_old_new(void *arg, struct got_fileindex_entry *ie, struct got_tree_entry *te, const char *parent_path) { + const struct got_error *err = NULL; struct diff_cb_arg *a = arg; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } return update_blob(a->worktree, a->fileindex, ie, te, ie->path, a->repo, a->progress_cb, a->progress_arg); @@ -2285,10 +2289,14 @@ diff_old_new(void *arg, struct got_fileindex_entry *ie static const struct got_error * diff_old(void *arg, struct got_fileindex_entry *ie, const char *parent_path) { + const struct got_error *err = NULL; struct diff_cb_arg *a = arg; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } return delete_blob(a->worktree, a->fileindex, ie, a->repo, a->progress_cb, a->progress_arg); @@ -2297,12 +2305,15 @@ diff_old(void *arg, struct got_fileindex_entry *ie, co static const struct got_error * diff_new(void *arg, struct got_tree_entry *te, const char *parent_path) { + const struct got_error *err = NULL; struct diff_cb_arg *a = arg; - const struct got_error *err; char *path; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (got_object_tree_entry_is_submodule(te)) return NULL; @@ -3246,7 +3257,7 @@ struct check_mixed_commits_args { static const struct got_error * check_mixed_commits(void *arg, struct got_fileindex_entry *ie) { - const struct got_error *err; + const struct got_error *err = NULL; struct check_mixed_commits_args *a = arg; if (a->cancel_cb) { @@ -3592,8 +3603,11 @@ status_old_new(void *arg, struct got_fileindex_entry * struct diff_dir_cb_arg *a = arg; char *abspath; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (got_path_cmp(parent_path, a->status_path, strlen(parent_path), a->status_path_len) != 0 && @@ -3619,12 +3633,16 @@ status_old_new(void *arg, struct got_fileindex_entry * static const struct got_error * status_old(void *arg, struct got_fileindex_entry *ie, const char *parent_path) { + const struct got_error *err; struct diff_dir_cb_arg *a = arg; struct got_object_id blob_id, commit_id; unsigned char status; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (!got_path_is_child(ie->path, a->status_path, a->status_path_len)) return NULL; @@ -3846,8 +3864,11 @@ status_new(int *ignore, void *arg, struct dirent *de, if (ignore != NULL) *ignore = 0; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (parent_path[0]) { if (asprintf(&path, "%s/%s", parent_path, de->d_name) == -1) @@ -9727,6 +9748,7 @@ struct report_file_info_arg { static const struct got_error * report_file_info(void *arg, struct got_fileindex_entry *ie) { + const struct got_error *err; struct report_file_info_arg *a = arg; struct got_pathlist_entry *pe; struct got_object_id blob_id, staged_blob_id, commit_id; @@ -9734,8 +9756,11 @@ report_file_info(void *arg, struct got_fileindex_entry struct got_object_id *commit_idp = NULL; int stage; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } TAILQ_FOREACH(pe, a->paths, entry) { if (pe->path_len == 0 || strcmp(pe->path, ie->path) == 0 || blob - 60d6d90c718edb4cbd775eb19fd4aaa26b0e8f65 blob + f488cd9dcd98b68c647973cb84a54e18daefced4 --- lib/worktree_cvg.c +++ lib/worktree_cvg.c @@ -695,8 +695,11 @@ status_old_new(void *arg, struct got_fileindex_entry * struct diff_dir_cb_arg *a = arg; char *abspath; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (got_path_cmp(parent_path, a->status_path, strlen(parent_path), a->status_path_len) != 0 && @@ -722,12 +725,16 @@ status_old_new(void *arg, struct got_fileindex_entry * static const struct got_error * status_old(void *arg, struct got_fileindex_entry *ie, const char *parent_path) { + const struct got_error *err = NULL; struct diff_dir_cb_arg *a = arg; struct got_object_id blob_id, commit_id; unsigned char status; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (!got_path_is_child(ie->path, a->status_path, a->status_path_len)) return NULL; @@ -949,8 +956,11 @@ status_new(int *ignore, void *arg, struct dirent *de, if (ignore != NULL) *ignore = 0; - if (a->cancel_cb && a->cancel_cb(a->cancel_arg)) - return got_error(GOT_ERR_CANCELLED); + if (a->cancel_cb) { + err = a->cancel_cb(a->cancel_arg); + if (err) + return err; + } if (parent_path[0]) { if (asprintf(&path, "%s/%s", parent_path, de->d_name) == -1)