From 680f306d361609a818e8d9ebb382286be084263c Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 11 Mar 2014 16:41:11 -0700 Subject: Warnings that default to being errors This is a try at extending the warning API to include warnings that would be errors unless the user callback decides to demote them to warnings. This allows for relaxed parsing logic that will default to strict behavior but can continue if possible. --- include/git2/sys/warning.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/git2/sys/warning.h') diff --git a/include/git2/sys/warning.h b/include/git2/sys/warning.h index ec1262a6b..02adfbe40 100644 --- a/include/git2/sys/warning.h +++ b/include/git2/sys/warning.h @@ -11,8 +11,10 @@ GIT_BEGIN_DECL typedef enum { GIT_WARNING_NONE = 0, - GIT_WARNING_INVALID_DATA__SIGNATURE_TIMESTAMP, - GIT_WARNING_INVALID_DATA__SIGNATURE_TIMEZONE, + GIT_WARNING_INVALID_DATA__SIGNATURE_TIMESTAMP, /* default continue */ + GIT_WARNING_INVALID_DATA__SIGNATURE_TIMEZONE, /* default continue */ + GIT_WARNING_INVALID_DATA__SIGNATURE_EMAIL_MISSING, /* default error */ + GIT_WARNING_INVALID_DATA__SIGNATURE_EMAIL_UNTERMINATED, /* error */ } git_warning_t; /** @@ -42,10 +44,13 @@ typedef struct { * It will be passed a warning structure describing the problem. * * @param warning A git_warning structure for the specific situation + * @param default_rval Default return code (i.e. <0 if warning defaults + * to error, 0 if defaults to no error) * @param payload The payload set when callback function was specified * @return 0 to continue, <0 to convert the warning to an error */ -typedef int (*git_warning_callback)(git_warning *warning, void *payload); +typedef int (*git_warning_callback)( + git_warning *warning, int default_rval, void *payload); /** * Set the callback to be invoked when an invalid but recoverable -- cgit v1.2.1