Commit fcc7dcb1 by Edward Thomson

errors: remove giterr usage in examples

parent 115a6c50
......@@ -132,7 +132,7 @@ static int perform_checkout_ref(git_repository *repo, git_annotated_commit *targ
/** Grab the commit we're interested to move to */
err = git_commit_lookup(&target_commit, repo, git_annotated_commit_id(target));
if (err != 0) {
fprintf(stderr, "failed to lookup commit: %s\n", giterr_last()->message);
fprintf(stderr, "failed to lookup commit: %s\n", git_error_last()->message);
goto cleanup;
}
......@@ -140,12 +140,12 @@ static int perform_checkout_ref(git_repository *repo, git_annotated_commit *targ
* Perform the checkout so the workdir corresponds to what target_commit
* contains.
*
* Note that it's okay to pass a git_commit here, because it will be
* Note that it's okay to pass a git_commit here, because it will be
* peeled to a tree.
*/
err = git_checkout_tree(repo, (const git_object *)target_commit, &checkout_opts);
if (err != 0) {
fprintf(stderr, "failed to checkout tree: %s\n", giterr_last()->message);
fprintf(stderr, "failed to checkout tree: %s\n", git_error_last()->message);
goto cleanup;
}
......@@ -161,7 +161,7 @@ static int perform_checkout_ref(git_repository *repo, git_annotated_commit *targ
err = git_repository_set_head_detached_from_annotated(repo, target);
}
if (err != 0) {
fprintf(stderr, "failed to update HEAD reference: %s\n", giterr_last()->message);
fprintf(stderr, "failed to update HEAD reference: %s\n", git_error_last()->message);
goto cleanup;
}
......@@ -219,7 +219,7 @@ int main(int argc, char **argv)
*/
err = resolve_refish(&checkout_target, repo, args.argv[args.pos]);
if (err != 0) {
fprintf(stderr, "failed to resolve %s: %s\n", args.argv[args.pos], giterr_last()->message);
fprintf(stderr, "failed to resolve %s: %s\n", args.argv[args.pos], git_error_last()->message);
goto cleanup;
}
err = perform_checkout_ref(repo, checkout_target, &opts);
......
......@@ -24,7 +24,7 @@ void check_lg2(int error, const char *message, const char *extra)
if (!error)
return;
if ((lg2err = giterr_last()) != NULL && lg2err->message != NULL) {
if ((lg2err = git_error_last()) != NULL && lg2err->message != NULL) {
lg2msg = lg2err->message;
lg2spacer = " - ";
}
......
......@@ -66,7 +66,7 @@ static void config_files(const char *repo_path, git_repository *repo);
*/
static void check_error(int error_code, const char *action)
{
const git_error *error = giterr_last();
const git_error *error = git_error_last();
if (!error_code)
return;
......
......@@ -96,7 +96,7 @@ static int resolve_heads(git_repository *repo, merge_options *opts)
for (i = 0; i < opts->heads_count; i++) {
err = resolve_refish(&annotated[annotated_count++], repo, opts->heads[i]);
if (err != 0) {
fprintf(stderr, "failed to resolve refish %s: %s\n", opts->heads[i], giterr_last()->message);
fprintf(stderr, "failed to resolve refish %s: %s\n", opts->heads[i], git_error_last()->message);
annotated_count--;
continue;
}
......@@ -229,7 +229,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, merge_opt
/* Maybe that's a ref, so DWIM it */
err = git_reference_dwim(&merge_ref, repo, opts->heads[0]);
check_lg2(err, "failed to DWIM reference", giterr_last()->message);
check_lg2(err, "failed to DWIM reference", git_error_last()->message);
/* Grab a signature */
check_lg2(git_signature_now(&sign, "Me", "me@example.com"), "failed to create signature", NULL);
......
......@@ -104,7 +104,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
error = git_clone(&cloned_repo, url, path, &clone_opts);
printf("\n");
if (error != 0) {
const git_error *err = giterr_last();
const git_error *err = git_error_last();
if (err) printf("ERROR %d: %s\n", err->klass, err->message);
else printf("ERROR %d: no detailed info\n", error);
}
......
......@@ -26,10 +26,10 @@ static int run_command(git_cb fn, git_repository *repo, struct args_info args)
/* Run the command. If something goes wrong, print the error message to stderr */
error = fn(repo, args.argc - args.pos, &args.argv[args.pos]);
if (error < 0) {
if (giterr_last() == NULL)
if (git_error_last() == NULL)
fprintf(stderr, "Error without message");
else
fprintf(stderr, "Bad news:\n %s\n", giterr_last()->message);
fprintf(stderr, "Bad news:\n %s\n", git_error_last()->message);
}
return !!error;
......
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