Commit fcc7dcb1762bbc01ef0088b4cc866ca712622e3a

Edward Thomson 2019-01-10T22:39:56

errors: remove giterr usage in examples

diff --git a/examples/checkout.c b/examples/checkout.c
index f92ad73..9119d65 100644
--- a/examples/checkout.c
+++ b/examples/checkout.c
@@ -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);
diff --git a/examples/common.c b/examples/common.c
index 4e0949b..e20767a 100644
--- a/examples/common.c
+++ b/examples/common.c
@@ -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 = " - ";
 	}
diff --git a/examples/general.c b/examples/general.c
index 7080cde..0b93a2e 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -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;
 
diff --git a/examples/merge.c b/examples/merge.c
index 761bd3a..13e3f96 100644
--- a/examples/merge.c
+++ b/examples/merge.c
@@ -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);
diff --git a/examples/network/clone.c b/examples/network/clone.c
index ce4b6ae..bbcd2e8 100644
--- a/examples/network/clone.c
+++ b/examples/network/clone.c
@@ -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);
 	}
diff --git a/examples/network/git2.c b/examples/network/git2.c
index 1d3d27b..d0d0eb6 100644
--- a/examples/network/git2.c
+++ b/examples/network/git2.c
@@ -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;