Commit c7b3e1b3 by Russell Belfer

Some callback error check style cleanups

I find this easier to read...
parent 60058018
...@@ -191,10 +191,11 @@ int git_attr_foreach( ...@@ -191,10 +191,11 @@ int git_attr_foreach(
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
error = GITERR_CALLBACK( error = callback(assign->name, assign->value, payload);
callback(assign->name, assign->value, payload) ); if (error) {
if (error) GITERR_CALLBACK(error);
goto cleanup; goto cleanup;
}
} }
} }
} }
......
...@@ -1388,8 +1388,10 @@ int git_diff__paired_foreach( ...@@ -1388,8 +1388,10 @@ int git_diff__paired_foreach(
i++; j++; i++; j++;
} }
if ((error = GITERR_CALLBACK( cb(h2i, i2w, payload) )) != 0) if ((error = cb(h2i, i2w, payload)) != 0) {
GITERR_CALLBACK(error);
break; break;
}
} }
/* restore case-insensitive delta sort */ /* restore case-insensitive delta sort */
......
...@@ -260,8 +260,8 @@ int git_repository_fetchhead_foreach(git_repository *repo, ...@@ -260,8 +260,8 @@ int git_repository_fetchhead_foreach(git_repository *repo,
while ((line = git__strsep(&buffer, "\n")) != NULL) { while ((line = git__strsep(&buffer, "\n")) != NULL) {
++line_num; ++line_num;
if ((error = fetchhead_ref_parse(&oid, &is_merge, &name, &remote_url, if ((error = fetchhead_ref_parse(
line, line_num)) < 0) &oid, &is_merge, &name, &remote_url, line, line_num)) < 0)
goto done; goto done;
if (git_buf_len(&name) > 0) if (git_buf_len(&name) > 0)
...@@ -269,10 +269,11 @@ int git_repository_fetchhead_foreach(git_repository *repo, ...@@ -269,10 +269,11 @@ int git_repository_fetchhead_foreach(git_repository *repo,
else else
ref_name = NULL; ref_name = NULL;
error = GITERR_CALLBACK( error = cb(ref_name, remote_url, &oid, is_merge, payload);
cb(ref_name, remote_url, &oid, is_merge, payload) ); if (error) {
if (error) GITERR_CALLBACK(error);
goto done; goto done;
}
} }
if (*buffer) { if (*buffer) {
......
...@@ -287,8 +287,10 @@ int git_repository_mergehead_foreach( ...@@ -287,8 +287,10 @@ int git_repository_mergehead_foreach(
if ((error = git_oid_fromstr(&oid, line)) < 0) if ((error = git_oid_fromstr(&oid, line)) < 0)
goto cleanup; goto cleanup;
if ((error = GITERR_CALLBACK( cb(&oid, payload) )) != 0) if ((error = cb(&oid, payload)) != 0) {
GITERR_CALLBACK(error);
goto cleanup; goto cleanup;
}
++line_num; ++line_num;
} }
......
...@@ -229,9 +229,12 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, ...@@ -229,9 +229,12 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
if (elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) { if (elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
pb->last_progress_report_time = current_time; pb->last_progress_report_time = current_time;
return GITERR_CALLBACK( pb->progress_cb( ret = pb->progress_cb(
GIT_PACKBUILDER_ADDING_OBJECTS, GIT_PACKBUILDER_ADDING_OBJECTS,
pb->nr_objects, 0, pb->progress_cb_payload) ); pb->nr_objects, 0, pb->progress_cb_payload);
if (ret)
return GITERR_CALLBACK(ret);
} }
} }
......
...@@ -1088,8 +1088,10 @@ int git_pack_foreach_entry( ...@@ -1088,8 +1088,10 @@ int git_pack_foreach_entry(
} }
for (i = 0; i < p->num_objects; i++) for (i = 0; i < p->num_objects; i++)
if ((error = GITERR_CALLBACK( cb(p->oids[i], data) )) != 0) if ((error = cb(p->oids[i], data)) != 0) {
GITERR_CALLBACK(error);
break; break;
}
return error; return error;
} }
......
...@@ -434,10 +434,13 @@ int git_path_walk_up( ...@@ -434,10 +434,13 @@ int git_path_walk_up(
iter.asize = path->asize; iter.asize = path->asize;
while (scan >= stop) { while (scan >= stop) {
error = GITERR_CALLBACK( cb(data, &iter) ); error = cb(data, &iter);
iter.ptr[scan] = oldc; iter.ptr[scan] = oldc;
if (error)
if (error) {
GITERR_CALLBACK(error);
break; break;
}
scan = git_buf_rfind_next(&iter, '/'); scan = git_buf_rfind_next(&iter, '/');
if (scan >= 0) { if (scan >= 0) {
...@@ -874,12 +877,14 @@ int git_path_direach( ...@@ -874,12 +877,14 @@ int git_path_direach(
if ((error = git_buf_put(path, de_path, de_len)) < 0) if ((error = git_buf_put(path, de_path, de_len)) < 0)
break; break;
error = GITERR_CALLBACK( fn(arg, path) ); error = fn(arg, path);
git_buf_truncate(path, wd_len); /* restore path */ git_buf_truncate(path, wd_len); /* restore path */
if (error) if (error != 0) {
GITERR_CALLBACK(error);
break; break;
}
} }
closedir(dir); closedir(dir);
......
...@@ -659,8 +659,9 @@ int git_push_status_foreach(git_push *push, ...@@ -659,8 +659,9 @@ int git_push_status_foreach(git_push *push,
unsigned int i; unsigned int i;
git_vector_foreach(&push->status, i, status) { git_vector_foreach(&push->status, i, status) {
GITERR_CHECK_ERROR( int error = cb(status->ref, status->msg, data);
GITERR_CALLBACK( cb(status->ref, status->msg, data) ) ); if (error)
return GITERR_CALLBACK(error);
} }
return 0; return 0;
......
...@@ -1348,9 +1348,11 @@ static int rename_fetch_refspecs( ...@@ -1348,9 +1348,11 @@ static int rename_fetch_refspecs(
if (!remote->name || if (!remote->name ||
strcmp(git_buf_cstr(&base), spec->string)) { strcmp(git_buf_cstr(&base), spec->string)) {
error = GITERR_CALLBACK( callback(spec->string, payload) ); if ((error = callback(spec->string, payload)) != 0) {
if (error) GITERR_CALLBACK(error);
break; break;
}
continue; continue;
} }
......
...@@ -582,13 +582,15 @@ int git_stash_foreach( ...@@ -582,13 +582,15 @@ int git_stash_foreach(
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
entry = git_reflog_entry_byindex(reflog, i); entry = git_reflog_entry_byindex(reflog, i);
error = GITERR_CALLBACK( error = callback(i,
callback(i, git_reflog_entry_message(entry),
git_reflog_entry_message(entry), git_reflog_entry_id_new(entry),
git_reflog_entry_id_new(entry), payload);
payload) );
if (error) if (error) {
GITERR_CALLBACK(error);
break; break;
}
} }
cleanup: cleanup:
......
...@@ -392,9 +392,10 @@ int git_status_foreach_ext( ...@@ -392,9 +392,10 @@ int git_status_foreach_ext(
status_entry->head_to_index->old_file.path : status_entry->head_to_index->old_file.path :
status_entry->index_to_workdir->old_file.path; status_entry->index_to_workdir->old_file.path;
error = GITERR_CALLBACK( cb(path, status_entry->status, payload) ); if ((error = cb(path, status_entry->status, payload)) != 0) {
if (error) GITERR_CALLBACK(error);
break; break;
}
} }
git_status_list_free(status); git_status_list_free(status);
......
...@@ -168,8 +168,10 @@ int git_submodule_foreach( ...@@ -168,8 +168,10 @@ int git_submodule_foreach(
break; break;
} }
if ((error = GITERR_CALLBACK(callback(sm, sm->name, payload))) != 0) if ((error = callback(sm, sm->name, payload)) != 0) {
GITERR_CALLBACK(error);
break; break;
}
}); });
git_vector_free(&seen); git_vector_free(&seen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment