diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-12-27 13:47:34 -0600 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-22 22:30:35 +0000 |
commit | f673e232afe22eb865cdc915e55a2df6493f0fbb (patch) | |
tree | e79e3e6fb1e1d78367679aea75e66c8141b4daa8 /tests | |
parent | 647dfdb42d06514a85c1499f1be88a32b8a4c24b (diff) | |
download | libgit2-f673e232afe22eb865cdc915e55a2df6493f0fbb.tar.gz |
git_error: use new names in internal APIs and usage
Move to the `git_error` name in the internal API for error-related
functions.
Diffstat (limited to 'tests')
43 files changed, 184 insertions, 184 deletions
diff --git a/tests/checkout/index.c b/tests/checkout/index.c index a4c811b6f..8272c68b3 100644 --- a/tests/checkout/index.c +++ b/tests/checkout/index.c @@ -548,15 +548,15 @@ void test_checkout_index__validates_struct_version(void) opts.version = 1024; cl_git_fail(git_checkout_index(g_repo, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(err->klass, GITERR_INVALID); + err = git_error_last(); + cl_assert_equal_i(err->klass, GIT_ERROR_INVALID); opts.version = 0; - giterr_clear(); + git_error_clear(); cl_git_fail(git_checkout_index(g_repo, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(err->klass, GITERR_INVALID); + err = git_error_last(); + cl_assert_equal_i(err->klass, GIT_ERROR_INVALID); } void test_checkout_index__can_update_prefixed_files(void) diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c index 740264ccc..4723a0632 100644 --- a/tests/clar_libgit2.c +++ b/tests/clar_libgit2.c @@ -7,7 +7,7 @@ void cl_git_report_failure( int error, int expected, const char *file, int line, const char *fncall) { char msg[4096]; - const git_error *last = giterr_last(); + const git_error *last = git_error_last(); if (expected) p_snprintf(msg, 4096, "error %d (expected %d) - %s", @@ -470,7 +470,7 @@ int cl_repo_get_bool(git_repository *repo, const char *cfg) git_config *config; cl_git_pass(git_repository_config(&config, repo)); if (git_config_get_bool(&val, config, cfg) < 0) - giterr_clear(); + git_error_clear(); git_config_free(config); return val; } diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h index 8a0ff4f20..da6ff2974 100644 --- a/tests/clar_libgit2.h +++ b/tests/clar_libgit2.h @@ -18,7 +18,7 @@ #define cl_git_expect(expr, expected, file, line) do { \ int _lg2_error; \ - giterr_clear(); \ + git_error_clear(); \ if ((_lg2_error = (expr)) != expected) \ cl_git_report_failure(_lg2_error, expected, file, line, "Function call failed: " #expr); \ } while (0) @@ -29,7 +29,7 @@ * calls that are supposed to fail! */ #define cl_git_fail(expr) do { \ - giterr_clear(); \ + git_error_clear(); \ if ((expr) == 0) \ cl_git_report_failure(0, 0, __FILE__, __LINE__, "Function call succeeded: " #expr); \ } while (0) @@ -40,7 +40,7 @@ #define cl_win32_pass(expr) do { \ int _win32_res; \ if ((_win32_res = (expr)) == 0) { \ - giterr_set(GITERR_OS, "Returned: %d, system error code: %lu", _win32_res, GetLastError()); \ + git_error_set(GIT_ERROR_OS, "Returned: %d, system error code: %lu", _win32_res, GetLastError()); \ cl_git_report_failure(_win32_res, 0, __FILE__, __LINE__, "System call failed: " #expr); \ } \ } while(0) @@ -70,9 +70,9 @@ typedef struct { #endif #define cl_git_thread_pass_(__threaderr, __expr, __file, __line) do { \ - giterr_clear(); \ + git_error_clear(); \ if ((((cl_git_thread_err *)__threaderr)->error = (__expr)) != 0) { \ - const git_error *_last = giterr_last(); \ + const git_error *_last = git_error_last(); \ ((cl_git_thread_err *)__threaderr)->file = __file; \ ((cl_git_thread_err *)__threaderr)->line = __line; \ ((cl_git_thread_err *)__threaderr)->expr = "Function call failed: " #__expr; \ diff --git a/tests/commit/parse.c b/tests/commit/parse.c index a5dcf8709..f0a31de9a 100644 --- a/tests/commit/parse.c +++ b/tests/commit/parse.c @@ -531,12 +531,12 @@ corrupt signature\n"; /* Try to parse a tree */ cl_git_pass(git_oid_fromstr(&commit_id, "45dd856fdd4d89b884c340ba0e047752d9b085d6")); cl_git_fail_with(GIT_ENOTFOUND, git_commit_extract_signature(&signature, &signed_data, g_repo, &commit_id, NULL)); - cl_assert_equal_i(GITERR_INVALID, giterr_last()->klass); + cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass); /* Try to parse an unsigned commit */ cl_git_pass(git_odb_write(&commit_id, odb, passing_commit_cases[1], strlen(passing_commit_cases[1]), GIT_OBJECT_COMMIT)); cl_git_fail_with(GIT_ENOTFOUND, git_commit_extract_signature(&signature, &signed_data, g_repo, &commit_id, NULL)); - cl_assert_equal_i(GITERR_OBJECT, giterr_last()->klass); + cl_assert_equal_i(GIT_ERROR_OBJECT, git_error_last()->klass); /* Parse the commit with a single-line signature */ git_buf_clear(&signature); diff --git a/tests/config/backend.c b/tests/config/backend.c index 18c4ca59e..96feecc4a 100644 --- a/tests/config/backend.c +++ b/tests/config/backend.c @@ -11,14 +11,14 @@ void test_config_backend__checks_version(void) cl_git_pass(git_config_new(&cfg)); cl_git_fail(git_config_add_backend(cfg, &backend, 0, NULL, false)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); - giterr_clear(); + git_error_clear(); backend.version = 1024; cl_git_fail(git_config_add_backend(cfg, &backend, 0, NULL, false)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); git_config_free(cfg); } diff --git a/tests/config/include.c b/tests/config/include.c index bab59bcbe..44546933b 100644 --- a/tests/config/include.c +++ b/tests/config/include.c @@ -101,9 +101,9 @@ void test_config_include__missing(void) { cl_git_mkfile("including", "[include]\npath = nonexistentfile\n[foo]\nbar = baz"); - giterr_clear(); + git_error_clear(); cl_git_pass(git_config_open_ondisk(&cfg, "including")); - cl_assert(giterr_last() == NULL); + cl_assert(git_error_last() == NULL); cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar")); cl_assert_equal_s("baz", git_buf_cstr(&buf)); @@ -115,9 +115,9 @@ void test_config_include__missing_homedir(void) cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, cl_fixture("config"))); cl_git_mkfile("including", "[include]\npath = ~/.nonexistentfile\n[foo]\nbar = baz"); - giterr_clear(); + git_error_clear(); cl_git_pass(git_config_open_ondisk(&cfg, "including")); - cl_assert(giterr_last() == NULL); + cl_assert(git_error_last() == NULL); cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar")); cl_assert_equal_s("baz", git_buf_cstr(&buf)); diff --git a/tests/config/rename.c b/tests/config/rename.c index a4614158a..be620c307 100644 --- a/tests/config/rename.c +++ b/tests/config/rename.c @@ -66,7 +66,7 @@ void test_config_rename__prevent_overwrite(void) /* so, we don't currently prevent overwrite... */ /* { const git_error *err; - cl_assert((err = giterr_last()) != NULL); + cl_assert((err = git_error_last()) != NULL); cl_assert(err->message != NULL); } */ } diff --git a/tests/core/errors.c b/tests/core/errors.c index ab18951a6..386ecdc5f 100644 --- a/tests/core/errors.c +++ b/tests/core/errors.c @@ -4,26 +4,26 @@ void test_core_errors__public_api(void) { char *str_in_error; - giterr_clear(); - cl_assert(giterr_last() == NULL); + git_error_clear(); + cl_assert(git_error_last() == NULL); - giterr_set_oom(); + git_error_set_oom(); - cl_assert(giterr_last() != NULL); - cl_assert(giterr_last()->klass == GITERR_NOMEMORY); - str_in_error = strstr(giterr_last()->message, "memory"); + cl_assert(git_error_last() != NULL); + cl_assert(git_error_last()->klass == GIT_ERROR_NOMEMORY); + str_in_error = strstr(git_error_last()->message, "memory"); cl_assert(str_in_error != NULL); - giterr_clear(); + git_error_clear(); - giterr_set_str(GITERR_REPOSITORY, "This is a test"); + git_error_set_str(GIT_ERROR_REPOSITORY, "This is a test"); - cl_assert(giterr_last() != NULL); - str_in_error = strstr(giterr_last()->message, "This is a test"); + cl_assert(git_error_last() != NULL); + str_in_error = strstr(git_error_last()->message, "This is a test"); cl_assert(str_in_error != NULL); - giterr_clear(); - cl_assert(giterr_last() == NULL); + git_error_clear(); + cl_assert(git_error_last() == NULL); } #include "common.h" @@ -34,26 +34,26 @@ void test_core_errors__new_school(void) { char *str_in_error; - giterr_clear(); - cl_assert(giterr_last() == NULL); + git_error_clear(); + cl_assert(git_error_last() == NULL); - giterr_set_oom(); /* internal fn */ + git_error_set_oom(); /* internal fn */ - cl_assert(giterr_last() != NULL); - cl_assert(giterr_last()->klass == GITERR_NOMEMORY); - str_in_error = strstr(giterr_last()->message, "memory"); + cl_assert(git_error_last() != NULL); + cl_assert(git_error_last()->klass == GIT_ERROR_NOMEMORY); + str_in_error = strstr(git_error_last()->message, "memory"); cl_assert(str_in_error != NULL); - giterr_clear(); + git_error_clear(); - giterr_set(GITERR_REPOSITORY, "This is a test"); /* internal fn */ + git_error_set(GIT_ERROR_REPOSITORY, "This is a test"); /* internal fn */ - cl_assert(giterr_last() != NULL); - str_in_error = strstr(giterr_last()->message, "This is a test"); + cl_assert(git_error_last() != NULL); + str_in_error = strstr(git_error_last()->message, "This is a test"); cl_assert(str_in_error != NULL); - giterr_clear(); - cl_assert(giterr_last() == NULL); + git_error_clear(); + cl_assert(git_error_last() == NULL); do { struct stat st; @@ -61,74 +61,74 @@ void test_core_errors__new_school(void) cl_assert(p_lstat("this_file_does_not_exist", &st) < 0); GIT_UNUSED(st); } while (false); - giterr_set(GITERR_OS, "stat failed"); /* internal fn */ + git_error_set(GIT_ERROR_OS, "stat failed"); /* internal fn */ - cl_assert(giterr_last() != NULL); - str_in_error = strstr(giterr_last()->message, "stat failed"); + cl_assert(git_error_last() != NULL); + str_in_error = strstr(git_error_last()->message, "stat failed"); cl_assert(str_in_error != NULL); cl_assert(git__prefixcmp(str_in_error, "stat failed: ") == 0); cl_assert(strlen(str_in_error) > strlen("stat failed: ")); #ifdef GIT_WIN32 - giterr_clear(); + git_error_clear(); /* The MSDN docs use this to generate a sample error */ cl_assert(GetProcessId(NULL) == 0); - giterr_set(GITERR_OS, "GetProcessId failed"); /* internal fn */ + git_error_set(GIT_ERROR_OS, "GetProcessId failed"); /* internal fn */ - cl_assert(giterr_last() != NULL); - str_in_error = strstr(giterr_last()->message, "GetProcessId failed"); + cl_assert(git_error_last() != NULL); + str_in_error = strstr(git_error_last()->message, "GetProcessId failed"); cl_assert(str_in_error != NULL); cl_assert(git__prefixcmp(str_in_error, "GetProcessId failed: ") == 0); cl_assert(strlen(str_in_error) > strlen("GetProcessId failed: ")); #endif - giterr_clear(); + git_error_clear(); } void test_core_errors__restore(void) { git_error_state err_state = {0}; - giterr_clear(); - cl_assert(giterr_last() == NULL); + git_error_clear(); + cl_assert(git_error_last() == NULL); - cl_assert_equal_i(0, giterr_state_capture(&err_state, 0)); + cl_assert_equal_i(0, git_error_state_capture(&err_state, 0)); memset(&err_state, 0x0, sizeof(git_error_state)); - giterr_set(42, "Foo: %s", "bar"); - cl_assert_equal_i(-1, giterr_state_capture(&err_state, -1)); + git_error_set(42, "Foo: %s", "bar"); + cl_assert_equal_i(-1, git_error_state_capture(&err_state, -1)); - cl_assert(giterr_last() == NULL); + cl_assert(git_error_last() == NULL); - giterr_set(99, "Bar: %s", "foo"); + git_error_set(99, "Bar: %s", "foo"); - giterr_state_restore(&err_state); + git_error_state_restore(&err_state); - cl_assert_equal_i(42, giterr_last()->klass); - cl_assert_equal_s("Foo: bar", giterr_last()->message); + cl_assert_equal_i(42, git_error_last()->klass); + cl_assert_equal_s("Foo: bar", git_error_last()->message); } void test_core_errors__free_state(void) { git_error_state err_state = {0}; - giterr_clear(); + git_error_clear(); - giterr_set(42, "Foo: %s", "bar"); - cl_assert_equal_i(-1, giterr_state_capture(&err_state, -1)); + git_error_set(42, "Foo: %s", "bar"); + cl_assert_equal_i(-1, git_error_state_capture(&err_state, -1)); - giterr_set(99, "Bar: %s", "foo"); + git_error_set(99, "Bar: %s", "foo"); - giterr_state_free(&err_state); + git_error_state_free(&err_state); - cl_assert_equal_i(99, giterr_last()->klass); - cl_assert_equal_s("Bar: foo", giterr_last()->message); + cl_assert_equal_i(99, git_error_last()->klass); + cl_assert_equal_s("Bar: foo", git_error_last()->message); - giterr_state_restore(&err_state); + git_error_state_restore(&err_state); - cl_assert(giterr_last() == NULL); + cl_assert(git_error_last() == NULL); } void test_core_errors__restore_oom(void) @@ -136,30 +136,30 @@ void test_core_errors__restore_oom(void) git_error_state err_state = {0}; const git_error *oom_error = NULL; - giterr_clear(); + git_error_clear(); - giterr_set_oom(); /* internal fn */ - oom_error = giterr_last(); + git_error_set_oom(); /* internal fn */ + oom_error = git_error_last(); cl_assert(oom_error); - cl_assert_equal_i(-1, giterr_state_capture(&err_state, -1)); + cl_assert_equal_i(-1, git_error_state_capture(&err_state, -1)); - cl_assert(giterr_last() == NULL); - cl_assert_equal_i(GITERR_NOMEMORY, err_state.error_msg.klass); + cl_assert(git_error_last() == NULL); + cl_assert_equal_i(GIT_ERROR_NOMEMORY, err_state.error_msg.klass); cl_assert_equal_s("Out of memory", err_state.error_msg.message); - giterr_state_restore(&err_state); + git_error_state_restore(&err_state); - cl_assert(giterr_last()->klass == GITERR_NOMEMORY); - cl_assert_(giterr_last() == oom_error, "static oom error not restored"); + cl_assert(git_error_last()->klass == GIT_ERROR_NOMEMORY); + cl_assert_(git_error_last() == oom_error, "static oom error not restored"); - giterr_clear(); + git_error_clear(); } static int test_arraysize_multiply(size_t nelem, size_t size) { size_t out; - GITERR_CHECK_ALLOC_MULTIPLY(&out, nelem, size); + GIT_ERROR_CHECK_ALLOC_MULTIPLY(&out, nelem, size); return 0; } @@ -174,14 +174,14 @@ void test_core_errors__integer_overflow_alloc_multiply(void) cl_git_fail(test_arraysize_multiply(SIZE_MAX-1, sizeof(void *))); cl_git_fail(test_arraysize_multiply((SIZE_MAX/sizeof(void *))+1, sizeof(void *))); - cl_assert_equal_i(GITERR_NOMEMORY, giterr_last()->klass); - cl_assert_equal_s("Out of memory", giterr_last()->message); + cl_assert_equal_i(GIT_ERROR_NOMEMORY, git_error_last()->klass); + cl_assert_equal_s("Out of memory", git_error_last()->message); } static int test_arraysize_add(size_t one, size_t two) { size_t out; - GITERR_CHECK_ALLOC_ADD(&out, one, two); + GIT_ERROR_CHECK_ALLOC_ADD(&out, one, two); return 0; } @@ -194,29 +194,29 @@ void test_core_errors__integer_overflow_alloc_add(void) cl_git_fail(test_arraysize_multiply(SIZE_MAX-1, 2)); cl_git_fail(test_arraysize_multiply(SIZE_MAX, SIZE_MAX)); - cl_assert_equal_i(GITERR_NOMEMORY, giterr_last()->klass); - cl_assert_equal_s("Out of memory", giterr_last()->message); + cl_assert_equal_i(GIT_ERROR_NOMEMORY, git_error_last()->klass); + cl_assert_equal_s("Out of memory", git_error_last()->message); } void test_core_errors__integer_overflow_sets_oom(void) { size_t out; - giterr_clear(); + git_error_clear(); cl_assert(!GIT_ADD_SIZET_OVERFLOW(&out, SIZE_MAX-1, 1)); - cl_assert_equal_p(NULL, giterr_last()); + cl_assert_equal_p(NULL, git_error_last()); - giterr_clear(); + git_error_clear(); cl_assert(!GIT_ADD_SIZET_OVERFLOW(&out, 42, 69)); - cl_assert_equal_p(NULL, giterr_last()); + cl_assert_equal_p(NULL, git_error_last()); - giterr_clear(); + git_error_clear(); cl_assert(GIT_ADD_SIZET_OVERFLOW(&out, SIZE_MAX, SIZE_MAX)); - cl_assert_equal_i(GITERR_NOMEMORY, giterr_last()->klass); - cl_assert_equal_s("Out of memory", giterr_last()->message); + cl_assert_equal_i(GIT_ERROR_NOMEMORY, git_error_last()->klass); + cl_assert_equal_s("Out of memory", git_error_last()->message); - giterr_clear(); + git_error_clear(); cl_assert(GIT_ADD_SIZET_OVERFLOW(&out, SIZE_MAX, SIZE_MAX)); - cl_assert_equal_i(GITERR_NOMEMORY, giterr_last()->klass); - cl_assert_equal_s("Out of memory", giterr_last()->message); + cl_assert_equal_i(GIT_ERROR_NOMEMORY, git_error_last()->klass); + cl_assert_equal_s("Out of memory", git_error_last()->message); } diff --git a/tests/core/sha1.c b/tests/core/sha1.c index c5b20f6e0..f81d40854 100644 --- a/tests/core/sha1.c +++ b/tests/core/sha1.c @@ -54,7 +54,7 @@ void test_core_sha1__detect_collision_attack(void) #ifdef GIT_SHA1_COLLISIONDETECT GIT_UNUSED(expected); cl_git_fail(sha1_file(&oid, FIXTURE_DIR "/shattered-1.pdf")); - cl_assert_equal_s("SHA1 collision attack detected", giterr_last()->message); + cl_assert_equal_s("SHA1 collision attack detected", git_error_last()->message); #else cl_git_pass(sha1_file(&oid, FIXTURE_DIR "/shattered-1.pdf")); git_oid_fromstr(&expected, "38762cf7f55934b34d179ae6a4c80cadccbb7f0a"); diff --git a/tests/core/strtol.c b/tests/core/strtol.c index 6f4e63af3..25dbe467c 100644 --- a/tests/core/strtol.c +++ b/tests/core/strtol.c @@ -121,6 +121,6 @@ void test_core_strtol__buffer_length_with_leading_sign_truncates(void) void test_core_strtol__error_message_cuts_off(void) { assert_l32_fails("2147483657foobar", 10); - cl_assert(strstr(giterr_last()->message, "2147483657") != NULL); - cl_assert(strstr(giterr_last()->message, "foobar") == NULL); + cl_assert(strstr(git_error_last()->message, "2147483657") != NULL); + cl_assert(strstr(git_error_last()->message, "foobar") == NULL); } diff --git a/tests/diff/blob.c b/tests/diff/blob.c index a876a973d..37898adcf 100644 --- a/tests/diff/blob.c +++ b/tests/diff/blob.c @@ -582,8 +582,8 @@ void test_diff_blob__checks_options_version_too_low(void) cl_git_fail(git_diff_blobs( d, NULL, alien, NULL, &opts, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); } void test_diff_blob__checks_options_version_too_high(void) @@ -594,8 +594,8 @@ void test_diff_blob__checks_options_version_too_high(void) cl_git_fail(git_diff_blobs( d, NULL, alien, NULL, &opts, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expected)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); } void test_diff_blob__can_correctly_detect_a_binary_blob_as_binary(void) diff --git a/tests/diff/diff_helpers.c b/tests/diff/diff_helpers.c index fdedd89ca..e9900339f 100644 --- a/tests/diff/diff_helpers.c +++ b/tests/diff/diff_helpers.c @@ -224,7 +224,7 @@ int diff_foreach_via_iterator( return 0; abort: - giterr_clear(); + git_error_clear(); return GIT_EUSER; } diff --git a/tests/diff/diffiter.c b/tests/diff/diffiter.c index 432201b7f..991c73bf4 100644 --- a/tests/diff/diffiter.c +++ b/tests/diff/diffiter.c @@ -441,13 +441,13 @@ void test_diff_diffiter__checks_options_version(void) opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; cl_git_fail(git_diff_index_to_workdir(&diff, repo, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); - giterr_clear(); + git_error_clear(); opts.version = 1024; cl_git_fail(git_diff_index_to_workdir(&diff, repo, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); } diff --git a/tests/diff/index.c b/tests/diff/index.c index 0293b7821..b616a372b 100644 --- a/tests/diff/index.c +++ b/tests/diff/index.c @@ -149,15 +149,15 @@ void test_diff_index__checks_options_version(void) opts.version = 0; cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); cl_assert_equal_p(diff, NULL); - giterr_clear(); + git_error_clear(); opts.version = 1024; cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); cl_assert_equal_p(diff, NULL); git_tree_free(a); diff --git a/tests/diff/rename.c b/tests/diff/rename.c index 2166ea521..df32eebf2 100644 --- a/tests/diff/rename.c +++ b/tests/diff/rename.c @@ -172,14 +172,14 @@ void test_diff_rename__checks_options_version(void) opts.version = 0; cl_git_fail(git_diff_find_similar(diff, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); - giterr_clear(); + git_error_clear(); opts.version = 1024; cl_git_fail(git_diff_find_similar(diff, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); git_diff_free(diff); git_tree_free(old_tree); diff --git a/tests/diff/tree.c b/tests/diff/tree.c index e4b2a8bbe..a3b00ec08 100644 --- a/tests/diff/tree.c +++ b/tests/diff/tree.c @@ -311,13 +311,13 @@ void test_diff_tree__checks_options_version(void) opts.version = 0; cl_git_fail(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); - giterr_clear(); + git_error_clear(); opts.version = 1024; cl_git_fail(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts)); - err = giterr_last(); + err = git_error_last(); } void process_tree_to_tree_diffing( diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c index f42121ff8..7a045b4fe 100644 --- a/tests/diff/workdir.c +++ b/tests/diff/workdir.c @@ -1221,14 +1221,14 @@ void test_diff_workdir__checks_options_version(void) opts.version = 0; cl_git_fail(git_diff_tree_to_workdir(&diff, g_repo, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); - giterr_clear(); + git_error_clear(); opts.version = 1024; cl_git_fail(git_diff_tree_to_workdir(&diff, g_repo, NULL, &opts)); - err = giterr_last(); - cl_assert_equal_i(GITERR_INVALID, err->klass); + err = git_error_last(); + cl_assert_equal_i(GIT_ERROR_INVALID, err->klass); } void test_diff_workdir__can_diff_empty_file(void) diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c index 6ea48a5f3..658943273 100644 --- a/tests/fetchhead/nonetwork.c +++ b/tests/fetchhead/nonetwork.c @@ -293,7 +293,7 @@ void test_fetchhead_nonetwork__invalid_for_merge(void) cl_git_rewritefile("./test1/.git/FETCH_HEAD", "49322bb17d3acc9146f98c97d078513228bbf3c0\tinvalid-merge\t\n"); cl_git_fail(git_repository_fetchhead_foreach(g_repo, read_noop, NULL)); - cl_assert(git__prefixcmp(giterr_last()->message, "invalid for-merge") == 0); + cl_assert(git__prefixcmp(git_error_last()->message, "invalid for-merge") == 0); } void test_fetchhead_nonetwork__invalid_description(void) @@ -304,7 +304,7 @@ void test_fetchhead_nonetwork__invalid_description(void) cl_git_rewritefile("./test1/.git/FETCH_HEAD", "49322bb17d3acc9146f98c97d078513228bbf3c0\tnot-for-merge\n"); cl_git_fail(git_repository_fetchhead_foreach(g_repo, read_noop, NULL)); - cl_assert(git__prefixcmp(giterr_last()->message, "invalid description") == 0); + cl_assert(git__prefixcmp(git_error_last()->message, "invalid description") == 0); } static int assert_master_for_merge(const char *ref, const char *url, const git_oid *id, unsigned int is_merge, void *data) diff --git a/tests/filter/crlf.c b/tests/filter/crlf.c index a98646271..a266005d4 100644 --- a/tests/filter/crlf.c +++ b/tests/filter/crlf.c @@ -97,14 +97,14 @@ void test_filter_crlf__with_safecrlf(void) in.size = strlen(in.ptr); cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in)); - cl_assert_equal_i(giterr_last()->klass, GITERR_FILTER); + cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_FILTER); /* Normalized \n fails for autocrlf=true when safecrlf=true */ in.ptr = "Normal\nLF\nonly\nline-endings.\n"; in.size = strlen(in.ptr); cl_git_fail(git_filter_list_apply_to_data(&out, fl, &in)); - cl_assert_equal_i(giterr_last()->klass, GITERR_FILTER); + cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_FILTER); /* String with \r but without \r\n does not fail with safecrlf */ in.ptr = "Normal\nCR only\rand some more\nline-endings.\n"; diff --git a/tests/filter/wildcard.c b/tests/filter/wildcard.c index ffa953121..3c25ea266 100644 --- a/tests/filter/wildcard.c +++ b/tests/filter/wildcard.c @@ -69,7 +69,7 @@ static int wildcard_filter_check( if (strcmp(attr_values[0], "wcflip") == 0 || strcmp(attr_values[0], "wcreverse") == 0) { *payload = git__strdup(attr_values[0]); - GITERR_CHECK_ALLOC(*payload); + GIT_ERROR_CHECK_ALLOC(*payload); return 0; } diff --git a/tests/index/crlf.c b/tests/index/crlf.c index d90ea582f..7aa6be429 100644 --- a/tests/index/crlf.c +++ b/tests/index/crlf.c @@ -82,8 +82,8 @@ static int add_and_check_file(void *payload, git_buf *actual_path) git_buf_rtrim(&expected_contents); if (git_index_add_bypath(g_index, basename) == 0 || - giterr_last()->klass != GITERR_FILTER || - strcmp(expected_contents.ptr, giterr_last()->message) != 0) + git_error_last()->klass != GIT_ERROR_FILTER || + strcmp(expected_contents.ptr, git_error_last()->message) != 0) goto done; } else { cl_fail("unexpected index failure"); diff --git a/tests/index/tests.c b/tests/index/tests.c index 49ef8b2cb..7c29ef389 100644 --- a/tests/index/tests.c +++ b/tests/index/tests.c @@ -849,8 +849,8 @@ void test_index_tests__elocked(void) error = git_index_write(index); cl_assert_equal_i(GIT_ELOCKED, error); - err = giterr_last(); - cl_assert_equal_i(err->klass, GITERR_INDEX); + err = git_error_last(); + cl_assert_equal_i(err->klass, GIT_ERROR_INDEX); git_filebuf_cleanup(&file); git_index_free(index); diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index ff11a3ea6..10517957d 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -73,8 +73,8 @@ void test_network_remote_remotes__error_when_not_found(void) git_remote *r; cl_git_fail_with(git_remote_lookup(&r, _repo, "does-not-exist"), GIT_ENOTFOUND); - cl_assert(giterr_last() != NULL); - cl_assert(giterr_last()->klass == GITERR_CONFIG); + cl_assert(git_error_last() != NULL); + cl_assert(git_error_last()->klass == GIT_ERROR_CONFIG); } void test_network_remote_remotes__error_when_no_push_available(void) @@ -337,8 +337,8 @@ void test_network_remote_remotes__can_load_with_an_empty_url(void) cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL)); - cl_assert(giterr_last() != NULL); - cl_assert(giterr_last()->klass == GITERR_INVALID); + cl_assert(git_error_last() != NULL); + cl_assert(git_error_last()->klass == GIT_ERROR_INVALID); git_remote_free(remote); } diff --git a/tests/object/tag/parse.c b/tests/object/tag/parse.c index 22535a025..2c0635ae4 100644 --- a/tests/object/tag/parse.c +++ b/tests/object/tag/parse.c @@ -214,5 +214,5 @@ void test_object_tag_parse__no_oob_read_when_searching_message(void) * expected one. */ assert_tag_fails(tag, strlen(tag) - strlen("\n\nMessage")); - cl_assert(strstr(giterr_last()->message, "tag contains no message")); + cl_assert(strstr(git_error_last()->message, "tag contains no message")); } diff --git a/tests/object/tree/parse.c b/tests/object/tree/parse.c index 1ab01c820..9d76a74f0 100644 --- a/tests/object/tree/parse.c +++ b/tests/object/tree/parse.c @@ -118,7 +118,7 @@ void test_object_tree_parse__mode_doesnt_cause_oob_read(void) * later fail to parse the OID with a different error * message */ - cl_assert_equal_s(giterr_last()->message, "failed to parse tree: missing space after filemode"); + cl_assert_equal_s(git_error_last()->message, "failed to parse tree: missing space after filemode"); } void test_object_tree_parse__unreasonably_large_mode_fails(void) diff --git a/tests/object/tree/write.c b/tests/object/tree/write.c index 8df69388c..9efeeb9b7 100644 --- a/tests/object/tree/write.c +++ b/tests/object/tree/write.c @@ -520,7 +520,7 @@ void test_object_tree_write__invalid_null_oid(void) cl_git_pass(git_treebuilder_new(&bld, g_repo, NULL)); cl_git_fail(git_treebuilder_insert(NULL, bld, "null_oid_file", &null_oid, GIT_FILEMODE_BLOB)); - cl_assert(giterr_last() && strstr(giterr_last()->message, "null OID") != NULL); + cl_assert(git_error_last() && strstr(git_error_last()->message, "null OID") != NULL); git_treebuilder_free(bld); } diff --git a/tests/odb/backend/backend_helpers.c b/tests/odb/backend/backend_helpers.c index c0f4103f1..139d2fc72 100644 --- a/tests/odb/backend/backend_helpers.c +++ b/tests/odb/backend/backend_helpers.c @@ -139,7 +139,7 @@ int build_fake_backend( fake_backend *backend; backend = git__calloc(1, sizeof(fake_backend)); - GITERR_CHECK_ALLOC(backend); + GIT_ERROR_CHECK_ALLOC(backend); backend->parent.version = GIT_ODB_BACKEND_VERSION; diff --git a/tests/odb/backend/nobackend.c b/tests/odb/backend/nobackend.c index cd727b7c4..7484d423b 100644 --- a/tests/odb/backend/nobackend.c +++ b/tests/odb/backend/nobackend.c @@ -39,7 +39,7 @@ void test_odb_backend_nobackend__write_fails_gracefully(void) git_repository_odb(&odb, _repo); cl_git_fail(git_odb_write(&id, odb, "Hello world!\n", 13, GIT_OBJECT_BLOB)); - err = giterr_last(); + err = git_error_last(); cl_assert_equal_s(err->message, "cannot write object - unsupported in the loaded odb backends"); git_odb_free(odb); diff --git a/tests/odb/backend/simple.c b/tests/odb/backend/simple.c index f4d29cc76..484dcba5a 100644 --- a/tests/odb/backend/simple.c +++ b/tests/odb/backend/simple.c @@ -246,5 +246,5 @@ void test_odb_backend_simple__null_oid_is_ignored(void) cl_assert(!git_odb_exists(_odb, &null_oid)); cl_git_fail_with(GIT_ENOTFOUND, git_odb_read(&obj, _odb, &null_oid)); - cl_assert(giterr_last() && strstr(giterr_last()->message, "null OID")); + cl_assert(git_error_last() && strstr(git_error_last()->message, "null OID")); } diff --git a/tests/online/clone.c b/tests/online/clone.c index 3f12a02a7..6fdbbbd01 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -472,7 +472,7 @@ static int cred_cb(git_cred **cred, const char *url, const char *user_from_url, _remote_user, _remote_ssh_pubkey, _remote_ssh_privkey, _remote_ssh_passphrase); - giterr_set(GITERR_NET, "unexpected cred type"); + git_error_set(GIT_ERROR_NET, "unexpected cred type"); return -1; } @@ -665,7 +665,7 @@ static int ssh_memory_cred_cb(git_cred **cred, const char *url, const char *user return ret; } - giterr_set(GITERR_NET, "unexpected cred type"); + git_error_set(GIT_ERROR_NET, "unexpected cred type"); return -1; } diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c index 7b1daa984..3c4e1c1ee 100644 --- a/tests/pack/indexer.c +++ b/tests/pack/indexer.c @@ -122,8 +122,8 @@ void test_pack_indexer__missing_trailer(void) idx, missing_trailer_pack, missing_trailer_pack_len, &stats)); cl_git_fail(git_indexer_commit(idx, &stats)); - cl_assert(giterr_last() != NULL); - cl_assert_equal_i(giterr_last()->klass, GITERR_INDEXER); + cl_assert(git_error_last() != NULL); + cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_INDEXER); git_indexer_free(idx); } @@ -138,8 +138,8 @@ void test_pack_indexer__leaky(void) idx, leaky_pack, leaky_pack_len, &stats)); cl_git_fail(git_indexer_commit(idx, &stats)); - cl_assert(giterr_last() != NULL); - cl_assert_equal_i(giterr_last()->klass, GITERR_INDEXER); + cl_assert(git_error_last() != NULL); + cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_INDEXER); git_indexer_free(idx); } @@ -231,8 +231,8 @@ void test_pack_indexer__corrupt_length(void) idx, corrupt_thin_pack, corrupt_thin_pack_len, &stats)); cl_git_fail(git_indexer_commit(idx, &stats)); - cl_assert(giterr_last() != NULL); - cl_assert_equal_i(giterr_last()->klass, GITERR_ZLIB); + cl_assert(git_error_last() != NULL); + cl_assert_equal_i(git_error_last()->klass, GIT_ERROR_ZLIB); git_indexer_free(idx); git_odb_free(odb); diff --git a/tests/refs/branches/move.c b/tests/refs/branches/move.c index acd8661b8..2cba9dfd3 100644 --- a/tests/refs/branches/move.c +++ b/tests/refs/branches/move.c @@ -84,7 +84,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "master", 0)); - cl_assert(giterr_last()->message != NULL); + cl_assert(git_error_last()->message != NULL); cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string(&str, config, "branch.master.remote")); @@ -96,7 +96,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "cannot-fetch", 0)); - cl_assert(giterr_last()->message != NULL); + cl_assert(git_error_last()->message != NULL); cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string(&str, config, "branch.master.remote")); @@ -111,7 +111,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "master", 0)); - cl_assert(giterr_last()->message != NULL); + cl_assert(git_error_last()->message != NULL); cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string(&str, config, "branch.master.remote")); diff --git a/tests/refs/branches/remote.c b/tests/refs/branches/remote.c index ac428abcb..27a3b0c44 100644 --- a/tests/refs/branches/remote.c +++ b/tests/refs/branches/remote.c @@ -34,10 +34,10 @@ void test_refs_branches_remote__no_matching_remote_returns_error(void) const char *unknown = "refs/remotes/nonexistent/master"; git_buf buf; - giterr_clear(); + git_error_clear(); memset(&buf, 0, sizeof(git_buf)); cl_git_fail_with(git_branch_remote_name(&buf, g_repo, unknown), GIT_ENOTFOUND); - cl_assert(giterr_last() != NULL); + cl_assert(git_error_last() != NULL); } void test_refs_branches_remote__local_remote_returns_error(void) @@ -45,10 +45,10 @@ void test_refs_branches_remote__local_remote_returns_error(void) const char *local = "refs/heads/master"; git_buf buf; - giterr_clear(); + git_error_clear(); memset(&buf, 0, sizeof(git_buf)); cl_git_fail_with(git_branch_remote_name(&buf, g_repo, local), GIT_ERROR); - cl_assert(giterr_last() != NULL); + cl_assert(git_error_last() != NULL); } void test_refs_branches_remote__ambiguous_remote_returns_error(void) @@ -61,8 +61,8 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void) git_remote_free(remote); - giterr_clear(); + git_error_clear(); memset(&buf, 0, sizeof(git_buf)); cl_git_fail_with(git_branch_remote_name(&buf, g_repo, remote_tracking_branch_name), GIT_EAMBIGUOUS); - cl_assert(giterr_last() != NULL); + cl_assert(git_error_last() != NULL); } diff --git a/tests/refs/branches/upstream.c b/tests/refs/branches/upstream.c index 176f2a509..928a9ff7b 100644 --- a/tests/refs/branches/upstream.c +++ b/tests/refs/branches/upstream.c @@ -176,7 +176,7 @@ void test_refs_branches_upstream__no_fetch_refspec(void) cl_git_pass(git_reference_create(&ref, repo, "refs/remotes/matching/master", git_reference_target(branch), 1, "fetch")); cl_git_fail(git_branch_set_upstream(branch, "matching/master")); cl_assert_equal_s("could not determine remote for 'refs/remotes/matching/master'", - giterr_last()->message); + git_error_last()->message); /* we can't set it automatically, so let's test the user setting it by hand */ cl_git_pass(git_repository_config(&cfg, repo)); diff --git a/tests/refs/lookup.c b/tests/refs/lookup.c index 456d0d2a8..01e956de2 100644 --- a/tests/refs/lookup.c +++ b/tests/refs/lookup.c @@ -64,5 +64,5 @@ void test_refs_lookup__dwim_notfound(void) git_reference *ref; cl_git_fail_with(GIT_ENOTFOUND, git_reference_dwim(&ref, g_repo, "idontexist")); - cl_assert_equal_s("no reference found for shorthand 'idontexist'", giterr_last()->message); + cl_assert_equal_s("no reference found for shorthand 'idontexist'", git_error_last()->message); } diff --git a/tests/refs/reflog/reflog.c b/tests/refs/reflog/reflog.c index 3a6c97c44..cf8c5c2d3 100644 --- a/tests/refs/reflog/reflog.c +++ b/tests/refs/reflog/reflog.c @@ -253,11 +253,11 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_returns_error cl_assert(strstr(git_buf_cstr(&logcontents), "Reflog\nmessage") != NULL); /* clear the error state so we can capture the error generated by git_reflog_read */ - giterr_clear(); + git_error_clear(); cl_git_fail(git_reflog_read(&reflog, g_repo, refname)); - error = giterr_last(); + error = git_error_last(); cl_assert(error != NULL); cl_assert_equal_s("unable to parse OID - contains invalid characters", error->message); diff --git a/tests/repo/shallow.c b/tests/repo/shallow.c index 5aeaf2def..b9a7b810b 100644 --- a/tests/repo/shallow.c +++ b/tests/repo/shallow.c @@ -35,5 +35,5 @@ void test_repo_shallow__clears_errors(void) { g_repo = cl_git_sandbox_init("testrepo.git"); cl_assert_equal_i(0, git_repository_is_shallow(g_repo)); - cl_assert_equal_p(NULL, giterr_last()); + cl_assert_equal_p(NULL, git_error_last()); } diff --git a/tests/threads/basic.c b/tests/threads/basic.c index 9ce740cf9..ed4fd2f9b 100644 --- a/tests/threads/basic.c +++ b/tests/threads/basic.c @@ -38,7 +38,7 @@ void test_threads_basic__multiple_init(void) static void *set_error(void *dummy) { - giterr_set(GITERR_INVALID, "oh no, something happened!\n"); + git_error_set(GIT_ERROR_INVALID, "oh no, something happened!\n"); return dummy; } diff --git a/tests/threads/diff.c b/tests/threads/diff.c index ab34b32a1..699642790 100644 --- a/tests/threads/diff.c +++ b/tests/threads/diff.c @@ -136,7 +136,7 @@ static void *run_index_diffs(void *arg) git_diff_free(diff); git_repository_free(repo); - giterr_clear(); + git_error_clear(); return arg; } @@ -203,7 +203,7 @@ static void *run_index_diffs_with_modifier(void *arg) done: git_index_free(idx); git_repository_free(repo); - giterr_clear(); + git_error_clear(); return arg; } diff --git a/tests/threads/iterator.c b/tests/threads/iterator.c index d93c89110..33d1bda81 100644 --- a/tests/threads/iterator.c +++ b/tests/threads/iterator.c @@ -41,7 +41,7 @@ static void *run_workdir_iterator(void *arg) git_iterator_free(iter); git_repository_free(repo); - giterr_clear(); + git_error_clear(); return arg; } diff --git a/tests/threads/refdb.c b/tests/threads/refdb.c index 94c5f5057..a4630df6a 100644 --- a/tests/threads/refdb.c +++ b/tests/threads/refdb.c @@ -58,7 +58,7 @@ static void *iterate_refs(void *arg) git_reference_iterator_free(i); git_repository_free(repo); - giterr_clear(); + git_error_clear(); return arg; } @@ -101,7 +101,7 @@ static void *create_refs(void *arg) git_repository_free(repo); - giterr_clear(); + git_error_clear(); return arg; } @@ -143,7 +143,7 @@ static void *delete_refs(void *arg) } git_repository_free(repo); - giterr_clear(); + git_error_clear(); return arg; } diff --git a/tests/valgrind-supp-mac.txt b/tests/valgrind-supp-mac.txt index 0cdc975fa..a104199e2 100644 --- a/tests/valgrind-supp-mac.txt +++ b/tests/valgrind-supp-mac.txt @@ -1,12 +1,12 @@ { - libgit2-giterr-set-buffer + libgit2-git-error-set-buffer Memcheck:Leak ... fun:git__realloc fun:git_buf_try_grow fun:git_buf_grow fun:git_buf_vprintf - fun:giterr_set + fun:git_error_set } { mac-setenv-leak-1 diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c index f5a95346b..bf5aac724 100644 --- a/tests/win32/longpath.c +++ b/tests/win32/longpath.c @@ -38,7 +38,7 @@ void assert_name_too_long(void) size_t expected_len, actual_len; char *expected_msg; - err = giterr_last(); + err = git_error_last(); actual_len = strlen(err->message); expected_msg = git_win32_get_error_message(ERROR_FILENAME_EXCED_RANGE); |