mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 10:28:56 +00:00
One more rename/cleanup for callback err functions
This commit is contained in:
parent
f10d7a368f
commit
26c1cb91be
@ -193,7 +193,7 @@ int git_attr_foreach(
|
||||
|
||||
error = callback(assign->name, assign->value, payload);
|
||||
if (error) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
@ -123,10 +123,13 @@ static int checkout_notify(
|
||||
path = delta->old_file.path;
|
||||
}
|
||||
|
||||
return giterr_set_callback(
|
||||
data->opts.notify_cb(
|
||||
why, path, baseline, target, workdir, data->opts.notify_payload),
|
||||
"git_checkout notification");
|
||||
{
|
||||
int error = data->opts.notify_cb(
|
||||
why, path, baseline, target, workdir, data->opts.notify_payload);
|
||||
|
||||
return giterr_set_after_callback_function(
|
||||
error, "git_checkout notification");
|
||||
}
|
||||
}
|
||||
|
||||
static bool checkout_is_workdir_modified(
|
||||
|
@ -83,7 +83,8 @@ int giterr_set_regex(const regex_t *regex, int error_code);
|
||||
*
|
||||
* @return This always returns the `error_code` parameter.
|
||||
*/
|
||||
GIT_INLINE(int) giterr_set_callback(int error_code, const char *action)
|
||||
GIT_INLINE(int) giterr_set_after_callback_function(
|
||||
int error_code, const char *action)
|
||||
{
|
||||
if (error_code) {
|
||||
const git_error *e = giterr_last();
|
||||
@ -95,9 +96,11 @@ GIT_INLINE(int) giterr_set_callback(int error_code, const char *action)
|
||||
}
|
||||
|
||||
#ifdef GIT_WIN32
|
||||
#define GITERR_CALLBACK(code) giterr_set_callback((code), __FUNCTION__)
|
||||
#define giterr_set_after_callback(code) \
|
||||
giterr_set_after_callback_function((code), __FUNCTION__)
|
||||
#else
|
||||
#define GITERR_CALLBACK(code) giterr_set_callback((code), __func__)
|
||||
#define giterr_set_after_callback(code) \
|
||||
giterr_set_after_callback_function((code), __func__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -508,7 +508,7 @@ int git_config_backend_foreach_match(
|
||||
|
||||
/* abort iterator on non-zero return value */
|
||||
if ((error = cb(entry, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -536,7 +536,7 @@ int git_config_foreach_match(
|
||||
|
||||
while (!(error = git_config_next(&entry, iter))) {
|
||||
if ((error = cb(entry, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -799,7 +799,7 @@ int git_config_get_multivar_foreach(
|
||||
found = 1;
|
||||
|
||||
if ((err = cb(entry, payload)) != 0) {
|
||||
GITERR_CALLBACK(err);
|
||||
giterr_set_after_callback(err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,11 @@ static int diff_insert_delta(
|
||||
|
||||
if (error) {
|
||||
git__free(delta);
|
||||
return (error > 0) ? 0 : giterr_set_callback(error, "git_diff");
|
||||
|
||||
if (error > 0) /* positive value means to skip this delta */
|
||||
return 0;
|
||||
else /* negative value means to cancel diff */
|
||||
return giterr_set_after_callback_function(error, "git_diff");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1389,7 +1393,7 @@ int git_diff__paired_foreach(
|
||||
}
|
||||
|
||||
if ((error = cb(h2i, i2w, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ static int diff_patch_invoke_file_callback(
|
||||
if (!output->file_cb)
|
||||
return 0;
|
||||
|
||||
return giterr_set_callback(
|
||||
return giterr_set_after_callback_function(
|
||||
output->file_cb(patch->delta, progress, output->payload),
|
||||
"git_patch");
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ int git_diff_print(
|
||||
diff, print_file, print_hunk, print_line, &pi);
|
||||
|
||||
if (error) /* make sure error message is set */
|
||||
giterr_set_callback(error, "git_diff_print");
|
||||
giterr_set_after_callback_function(error, "git_diff_print");
|
||||
}
|
||||
|
||||
git_buf_free(&buf);
|
||||
@ -427,7 +427,7 @@ int git_patch_print(
|
||||
diff_print_patch_line, &pi);
|
||||
|
||||
if (error) /* make sure error message is set */
|
||||
giterr_set_callback(error, "git_patch_print");
|
||||
giterr_set_after_callback_function(error, "git_patch_print");
|
||||
}
|
||||
|
||||
git_buf_free(&temp);
|
||||
|
@ -271,7 +271,7 @@ int git_repository_fetchhead_foreach(git_repository *repo,
|
||||
|
||||
error = cb(ref_name, remote_url, &oid, is_merge, payload);
|
||||
if (error) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
20
src/index.c
20
src/index.c
@ -2117,7 +2117,7 @@ int git_index_add_all(
|
||||
if (error > 0) /* return > 0 means skip this one */
|
||||
continue;
|
||||
if (error < 0) { /* return < 0 means abort */
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2204,10 +2204,8 @@ static int index_apply_to_all(
|
||||
error = 0;
|
||||
continue;
|
||||
}
|
||||
if (error < 0) { /* return < 0 means abort */
|
||||
giterr_set_callback(error, "git_index_matched_path");
|
||||
if (error < 0) /* return < 0 means abort */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* index manipulation may alter entry, so don't depend on it */
|
||||
@ -2252,8 +2250,13 @@ int git_index_remove_all(
|
||||
git_index_matched_path_cb cb,
|
||||
void *payload)
|
||||
{
|
||||
return index_apply_to_all(
|
||||
int error = index_apply_to_all(
|
||||
index, INDEX_ACTION_REMOVE, pathspec, cb, payload);
|
||||
|
||||
if (error) /* make sure error is set if callback stopped iteration */
|
||||
giterr_set_after_callback(error);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int git_index_update_all(
|
||||
@ -2262,6 +2265,11 @@ int git_index_update_all(
|
||||
git_index_matched_path_cb cb,
|
||||
void *payload)
|
||||
{
|
||||
return index_apply_to_all(
|
||||
int error = index_apply_to_all(
|
||||
index, INDEX_ACTION_UPDATE, pathspec, cb, payload);
|
||||
|
||||
if (error) /* make sure error is set if callback stopped iteration */
|
||||
giterr_set_after_callback(error);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ on_error:
|
||||
static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats)
|
||||
{
|
||||
if (idx->progress_cb)
|
||||
return giterr_set_callback(
|
||||
return giterr_set_after_callback_function(
|
||||
idx->progress_cb(stats, idx->progress_payload),
|
||||
"indexer progress");
|
||||
return 0;
|
||||
|
@ -288,7 +288,7 @@ int git_repository_mergehead_foreach(
|
||||
goto cleanup;
|
||||
|
||||
if ((error = cb(&oid, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ int git_note_foreach(
|
||||
|
||||
while (!(error = git_note_next(¬e_id, &annotated_id, iter))) {
|
||||
if ((error = note_cb(¬e_id, &annotated_id, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ static int foreach_object_dir_cb(void *_state, git_buf *path)
|
||||
if (filename_to_oid(&oid, path->ptr + state->dir_len) < 0)
|
||||
return 0;
|
||||
|
||||
return giterr_set_callback(
|
||||
return giterr_set_after_callback_function(
|
||||
state->cb(&oid, state->data), "git_odb_foreach");
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
|
||||
pb->nr_objects, 0, pb->progress_cb_payload);
|
||||
|
||||
if (ret)
|
||||
return GITERR_CALLBACK(ret);
|
||||
return giterr_set_after_callback(ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1088,10 +1088,8 @@ int git_pack_foreach_entry(
|
||||
}
|
||||
|
||||
for (i = 0; i < p->num_objects; i++)
|
||||
if ((error = cb(p->oids[i], data)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
break;
|
||||
}
|
||||
if ((error = cb(p->oids[i], data)) != 0)
|
||||
return giterr_set_after_callback(error);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ int git_path_walk_up(
|
||||
iter.ptr[scan] = oldc;
|
||||
|
||||
if (error) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -882,7 +882,7 @@ int git_path_direach(
|
||||
git_buf_truncate(path, wd_len); /* restore path */
|
||||
|
||||
if (error != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ int git_push_status_foreach(git_push *push,
|
||||
git_vector_foreach(&push->status, i, status) {
|
||||
int error = cb(status->ref, status->msg, data);
|
||||
if (error)
|
||||
return GITERR_CALLBACK(error);
|
||||
return giterr_set_after_callback(error);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -518,7 +518,7 @@ int git_reference_foreach(
|
||||
|
||||
while (!(error = git_reference_next(&ref, iter))) {
|
||||
if ((error = callback(ref, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -544,7 +544,7 @@ int git_reference_foreach_name(
|
||||
|
||||
while (!(error = git_reference_next_name(&refname, iter))) {
|
||||
if ((error = callback(refname, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -571,7 +571,7 @@ int git_reference_foreach_glob(
|
||||
|
||||
while (!(error = git_reference_next_name(&refname, iter))) {
|
||||
if ((error = callback(refname, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1349,7 +1349,7 @@ static int rename_fetch_refspecs(
|
||||
strcmp(git_buf_cstr(&base), spec->string)) {
|
||||
|
||||
if ((error = callback(spec->string, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ int git_stash_foreach(
|
||||
payload);
|
||||
|
||||
if (error) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ int git_status_foreach_ext(
|
||||
status_entry->index_to_workdir->old_file.path;
|
||||
|
||||
if ((error = cb(path, status_entry->status, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ int git_submodule_foreach(
|
||||
}
|
||||
|
||||
if ((error = callback(sm, sm->name, payload)) != 0) {
|
||||
GITERR_CALLBACK(error);
|
||||
giterr_set_after_callback(error);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
@ -426,8 +426,8 @@ static int tags_cb(const char *ref, void *data)
|
||||
return 0; /* no tag */
|
||||
|
||||
if (!(error = git_reference_name_to_id(&oid, d->repo, ref))) {
|
||||
error = d->cb(ref, &oid, d->cb_data);
|
||||
giterr_set_callback(error, "git_tag_foreach");
|
||||
if ((error = d->cb(ref, &oid, d->cb_data)) != 0)
|
||||
giterr_set_after_callback_function(error, "git_tag_foreach");
|
||||
}
|
||||
|
||||
return error;
|
||||
|
16
src/tree.c
16
src/tree.c
@ -883,9 +883,12 @@ static int tree_walk(
|
||||
|
||||
git_vector_foreach(&tree->entries, i, entry) {
|
||||
if (preorder) {
|
||||
if ((error = callback(path->ptr, entry, payload)) < 0)
|
||||
return giterr_set_callback(error, "git_tree_walk");
|
||||
if (error > 0) {
|
||||
error = callback(path->ptr, entry, payload);
|
||||
if (error < 0) { /* negative value stops iteration */
|
||||
giterr_set_after_callback_function(error, "git_tree_walk");
|
||||
break;
|
||||
}
|
||||
if (error > 0) { /* positive value skips this entry */
|
||||
error = 0;
|
||||
continue;
|
||||
}
|
||||
@ -916,8 +919,11 @@ static int tree_walk(
|
||||
}
|
||||
|
||||
if (!preorder) {
|
||||
if ((error = callback(path->ptr, entry, payload)) < 0)
|
||||
return giterr_set_callback(error, "git_tree_walk");
|
||||
error = callback(path->ptr, entry, payload);
|
||||
if (error < 0) { /* negative value stops iteration */
|
||||
giterr_set_after_callback_function(error, "git_tree_walk");
|
||||
break;
|
||||
}
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user