From 20961b9871f12814790ebed80d88692fbb962d4f Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Wed, 26 Dec 2018 14:06:21 -0600 Subject: git_error: use full class name in public error API Move to the `git_error` name in error-related functions, deprecating the `giterr` functions. This means, for example, that `giterr_last` is now `git_error_last`. The old names are retained for compatibility. This only updates the public API; internal API and function usage remains unchanged. --- include/git2/errors.h | 174 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 131 insertions(+), 43 deletions(-) (limited to 'include/git2/errors.h') diff --git a/include/git2/errors.h b/include/git2/errors.h index 2c0ac1c71..1b18473c0 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -73,42 +73,48 @@ typedef struct { /** Error classes */ typedef enum { - GITERR_NONE = 0, - GITERR_NOMEMORY, - GITERR_OS, - GITERR_INVALID, - GITERR_REFERENCE, - GITERR_ZLIB, - GITERR_REPOSITORY, - GITERR_CONFIG, - GITERR_REGEX, - GITERR_ODB, - GITERR_INDEX, - GITERR_OBJECT, - GITERR_NET, - GITERR_TAG, - GITERR_TREE, - GITERR_INDEXER, - GITERR_SSL, - GITERR_SUBMODULE, - GITERR_THREAD, - GITERR_STASH, - GITERR_CHECKOUT, - GITERR_FETCHHEAD, - GITERR_MERGE, - GITERR_SSH, - GITERR_FILTER, - GITERR_REVERT, - GITERR_CALLBACK, - GITERR_CHERRYPICK, - GITERR_DESCRIBE, - GITERR_REBASE, - GITERR_FILESYSTEM, - GITERR_PATCH, - GITERR_WORKTREE, - GITERR_SHA1 + GIT_ERROR_NONE = 0, + GIT_ERROR_NOMEMORY, + GIT_ERROR_OS, + GIT_ERROR_INVALID, + GIT_ERROR_REFERENCE, + GIT_ERROR_ZLIB, + GIT_ERROR_REPOSITORY, + GIT_ERROR_CONFIG, + GIT_ERROR_REGEX, + GIT_ERROR_ODB, + GIT_ERROR_INDEX, + GIT_ERROR_OBJECT, + GIT_ERROR_NET, + GIT_ERROR_TAG, + GIT_ERROR_TREE, + GIT_ERROR_INDEXER, + GIT_ERROR_SSL, + GIT_ERROR_SUBMODULE, + GIT_ERROR_THREAD, + GIT_ERROR_STASH, + GIT_ERROR_CHECKOUT, + GIT_ERROR_FETCHHEAD, + GIT_ERROR_MERGE, + GIT_ERROR_SSH, + GIT_ERROR_FILTER, + GIT_ERROR_REVERT, + GIT_ERROR_CALLBACK, + GIT_ERROR_CHERRYPICK, + GIT_ERROR_DESCRIBE, + GIT_ERROR_REBASE, + GIT_ERROR_FILESYSTEM, + GIT_ERROR_PATCH, + GIT_ERROR_WORKTREE, + GIT_ERROR_SHA1 } git_error_t; +/** @name Error Functions + * + * These functions report or set error information. + */ +/**@{*/ + /** * Return the last `git_error` object that was generated for the * current thread. @@ -120,12 +126,12 @@ typedef enum { * * @return A git_error object. */ -GIT_EXTERN(const git_error *) giterr_last(void); +GIT_EXTERN(const git_error *) git_error_last(void); /** * Clear the last library error that occurred for this thread. */ -GIT_EXTERN(void) giterr_clear(void); +GIT_EXTERN(void) git_error_clear(void); /** * Set the error message string for this thread. @@ -143,18 +149,100 @@ GIT_EXTERN(void) giterr_clear(void); * general subsystem that is responsible for the error. * @param string The formatted error message to keep */ -GIT_EXTERN(void) giterr_set_str(int error_class, const char *string); +GIT_EXTERN(void) git_error_set_str(int error_class, const char *string); /** * Set the error message to a special value for memory allocation failure. * - * The normal `giterr_set_str()` function attempts to `strdup()` the string - * that is passed in. This is not a good idea when the error in question - * is a memory allocation failure. That circumstance has a special setter - * function that sets the error string to a known and statically allocated - * internal value. + * The normal `git_error_set_str()` function attempts to `strdup()` the + * string that is passed in. This is not a good idea when the error in + * question is a memory allocation failure. That circumstance has a + * special setter function that sets the error string to a known and + * statically allocated internal value. + */ +GIT_EXTERN(void) git_error_set_oom(void); + +/**@}*/ + +/** @name Deprecated Error Functions + * + * These functions and enumeration values are retained for backward + * compatibility. The newer versions of these functions should be + * preferred in all new code. + */ +/**@{*/ + +#define GITERR_NONE GIT_ERROR_NONE +#define GITERR_NOMEMORY GIT_ERROR_NOMEMORY +#define GITERR_OS GIT_ERROR_OS +#define GITERR_INVALID GIT_ERROR_INVALID +#define GITERR_REFERENCE GIT_ERROR_REFERENCE +#define GITERR_ZLIB GIT_ERROR_ZLIB +#define GITERR_REPOSITORY GIT_ERROR_REPOSITORY +#define GITERR_CONFIG GIT_ERROR_CONFIG +#define GITERR_REGEX GIT_ERROR_REGEX +#define GITERR_ODB GIT_ERROR_ODB +#define GITERR_INDEX GIT_ERROR_INDEX +#define GITERR_OBJECT GIT_ERROR_OBJECT +#define GITERR_NET GIT_ERROR_NET +#define GITERR_TAG GIT_ERROR_TAG +#define GITERR_TREE GIT_ERROR_TREE +#define GITERR_INDEXER GIT_ERROR_INDEXER +#define GITERR_SSL GIT_ERROR_SSL +#define GITERR_SUBMODULE GIT_ERROR_SUBMODULE +#define GITERR_THREAD GIT_ERROR_THREAD +#define GITERR_STASH GIT_ERROR_STASH +#define GITERR_CHECKOUT GIT_ERROR_CHECKOUT +#define GITERR_FETCHHEAD GIT_ERROR_FETCHHEAD +#define GITERR_MERGE GIT_ERROR_MERGE +#define GITERR_SSH GIT_ERROR_SSH +#define GITERR_FILTER GIT_ERROR_FILTER +#define GITERR_REVERT GIT_ERROR_REVERT +#define GITERR_CALLBACK GIT_ERROR_CALLBACK +#define GITERR_CHERRYPICK GIT_ERROR_CHERRYPICK +#define GITERR_DESCRIBE GIT_ERROR_DESCRIBE +#define GITERR_REBASE GIT_ERROR_REBASE +#define GITERR_FILESYSTEM GIT_ERROR_FILESYSTEM +#define GITERR_PATCH GIT_ERROR_PATCH +#define GITERR_WORKTREE GIT_ERROR_WORKTREE +#define GITERR_SHA1 GIT_ERROR_SHA1 + +/** + * Return the last `git_error` object that was generated for the + * current thread. This function is deprecated and will be removed + * in a future release; `git_error_last` should be used instead. + * + * @see git_error_last */ -GIT_EXTERN(void) giterr_set_oom(void); +GIT_DEPRECATED(GIT_EXTERN(const git_error *)) giterr_last(void); + +/** + * Clear the last error. This function is deprecated and will be + * removed in a future release; `giterr_clear` should be used instead. + * + * @see git_error_last + */ +GIT_DEPRECATED(GIT_EXTERN(void)) giterr_clear(void); + +/** + * Sets the error message to the given string. This function is + * deprecated and will be removed in a future release; `giterr_clear` + * should be used instead. + * + * @see git_error_set_str + */ +GIT_DEPRECATED(GIT_EXTERN(void)) giterr_set_str(int error_class, const char *string); + +/** + * Indicates that an out-of-memory situation occured. This function + * is deprecated and will be removed in a future release; `giterr_clear` + * should be used instead. + * + * @see git_error_set_oom + */ +GIT_DEPRECATED(GIT_EXTERN(void)) giterr_set_oom(void); + +/**@}*/ /** @} */ GIT_END_DECL -- cgit v1.2.1 From 647dfdb42d06514a85c1499f1be88a32b8a4c24b Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 10 Jan 2019 22:13:07 +0000 Subject: git_error: deprecate error values Replace the `GITERR` values with a `const int` to deprecate error values. --- include/git2/errors.h | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'include/git2/errors.h') diff --git a/include/git2/errors.h b/include/git2/errors.h index 1b18473c0..f00385b8c 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -172,40 +172,40 @@ GIT_EXTERN(void) git_error_set_oom(void); */ /**@{*/ -#define GITERR_NONE GIT_ERROR_NONE -#define GITERR_NOMEMORY GIT_ERROR_NOMEMORY -#define GITERR_OS GIT_ERROR_OS -#define GITERR_INVALID GIT_ERROR_INVALID -#define GITERR_REFERENCE GIT_ERROR_REFERENCE -#define GITERR_ZLIB GIT_ERROR_ZLIB -#define GITERR_REPOSITORY GIT_ERROR_REPOSITORY -#define GITERR_CONFIG GIT_ERROR_CONFIG -#define GITERR_REGEX GIT_ERROR_REGEX -#define GITERR_ODB GIT_ERROR_ODB -#define GITERR_INDEX GIT_ERROR_INDEX -#define GITERR_OBJECT GIT_ERROR_OBJECT -#define GITERR_NET GIT_ERROR_NET -#define GITERR_TAG GIT_ERROR_TAG -#define GITERR_TREE GIT_ERROR_TREE -#define GITERR_INDEXER GIT_ERROR_INDEXER -#define GITERR_SSL GIT_ERROR_SSL -#define GITERR_SUBMODULE GIT_ERROR_SUBMODULE -#define GITERR_THREAD GIT_ERROR_THREAD -#define GITERR_STASH GIT_ERROR_STASH -#define GITERR_CHECKOUT GIT_ERROR_CHECKOUT -#define GITERR_FETCHHEAD GIT_ERROR_FETCHHEAD -#define GITERR_MERGE GIT_ERROR_MERGE -#define GITERR_SSH GIT_ERROR_SSH -#define GITERR_FILTER GIT_ERROR_FILTER -#define GITERR_REVERT GIT_ERROR_REVERT -#define GITERR_CALLBACK GIT_ERROR_CALLBACK -#define GITERR_CHERRYPICK GIT_ERROR_CHERRYPICK -#define GITERR_DESCRIBE GIT_ERROR_DESCRIBE -#define GITERR_REBASE GIT_ERROR_REBASE -#define GITERR_FILESYSTEM GIT_ERROR_FILESYSTEM -#define GITERR_PATCH GIT_ERROR_PATCH -#define GITERR_WORKTREE GIT_ERROR_WORKTREE -#define GITERR_SHA1 GIT_ERROR_SHA1 +GIT_DEPRECATED(static const int) GITERR_NONE = GIT_ERROR_NONE; +GIT_DEPRECATED(static const int) GITERR_NOMEMORY = GIT_ERROR_NOMEMORY; +GIT_DEPRECATED(static const int) GITERR_OS = GIT_ERROR_OS; +GIT_DEPRECATED(static const int) GITERR_INVALID = GIT_ERROR_INVALID; +GIT_DEPRECATED(static const int) GITERR_REFERENCE = GIT_ERROR_REFERENCE; +GIT_DEPRECATED(static const int) GITERR_ZLIB = GIT_ERROR_ZLIB; +GIT_DEPRECATED(static const int) GITERR_REPOSITORY = GIT_ERROR_REPOSITORY; +GIT_DEPRECATED(static const int) GITERR_CONFIG = GIT_ERROR_CONFIG; +GIT_DEPRECATED(static const int) GITERR_REGEX = GIT_ERROR_REGEX; +GIT_DEPRECATED(static const int) GITERR_ODB = GIT_ERROR_ODB; +GIT_DEPRECATED(static const int) GITERR_INDEX = GIT_ERROR_INDEX; +GIT_DEPRECATED(static const int) GITERR_OBJECT = GIT_ERROR_OBJECT; +GIT_DEPRECATED(static const int) GITERR_NET = GIT_ERROR_NET; +GIT_DEPRECATED(static const int) GITERR_TAG = GIT_ERROR_TAG; +GIT_DEPRECATED(static const int) GITERR_TREE = GIT_ERROR_TREE; +GIT_DEPRECATED(static const int) GITERR_INDEXER = GIT_ERROR_INDEXER; +GIT_DEPRECATED(static const int) GITERR_SSL = GIT_ERROR_SSL; +GIT_DEPRECATED(static const int) GITERR_SUBMODULE = GIT_ERROR_SUBMODULE; +GIT_DEPRECATED(static const int) GITERR_THREAD = GIT_ERROR_THREAD; +GIT_DEPRECATED(static const int) GITERR_STASH = GIT_ERROR_STASH; +GIT_DEPRECATED(static const int) GITERR_CHECKOUT = GIT_ERROR_CHECKOUT; +GIT_DEPRECATED(static const int) GITERR_FETCHHEAD = GIT_ERROR_FETCHHEAD; +GIT_DEPRECATED(static const int) GITERR_MERGE = GIT_ERROR_MERGE; +GIT_DEPRECATED(static const int) GITERR_SSH = GIT_ERROR_SSH; +GIT_DEPRECATED(static const int) GITERR_FILTER = GIT_ERROR_FILTER; +GIT_DEPRECATED(static const int) GITERR_REVERT = GIT_ERROR_REVERT; +GIT_DEPRECATED(static const int) GITERR_CALLBACK = GIT_ERROR_CALLBACK; +GIT_DEPRECATED(static const int) GITERR_CHERRYPICK = GIT_ERROR_CHERRYPICK; +GIT_DEPRECATED(static const int) GITERR_DESCRIBE = GIT_ERROR_DESCRIBE; +GIT_DEPRECATED(static const int) GITERR_REBASE = GIT_ERROR_REBASE; +GIT_DEPRECATED(static const int) GITERR_FILESYSTEM = GIT_ERROR_FILESYSTEM; +GIT_DEPRECATED(static const int) GITERR_PATCH = GIT_ERROR_PATCH; +GIT_DEPRECATED(static const int) GITERR_WORKTREE = GIT_ERROR_WORKTREE; +GIT_DEPRECATED(static const int) GITERR_SHA1 = GIT_ERROR_SHA1; /** * Return the last `git_error` object that was generated for the -- cgit v1.2.1