config: add CONFIG_ERROR_SILENT handler

We can currently die() or error(), but there's not yet any
way for callers to ask us just to quietly return an error.
Let's give them one.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2018-06-28 18:05:09 -04:00 committed by Junio C Hamano
parent 66f9722882
commit 63583203df
2 changed files with 4 additions and 0 deletions

View File

@ -818,6 +818,9 @@ static int git_parse_source(config_fn_t fn, void *data,
case CONFIG_ERROR_ERROR: case CONFIG_ERROR_ERROR:
error_return = error("%s", error_msg); error_return = error("%s", error_msg);
break; break;
case CONFIG_ERROR_SILENT:
error_return = -1;
break;
case CONFIG_ERROR_UNSET: case CONFIG_ERROR_UNSET:
BUG("config error action unset"); BUG("config error action unset");
} }

View File

@ -58,6 +58,7 @@ struct config_options {
CONFIG_ERROR_UNSET = 0, /* use source-specific default */ CONFIG_ERROR_UNSET = 0, /* use source-specific default */
CONFIG_ERROR_DIE, /* die() on error */ CONFIG_ERROR_DIE, /* die() on error */
CONFIG_ERROR_ERROR, /* error() on error, return -1 */ CONFIG_ERROR_ERROR, /* error() on error, return -1 */
CONFIG_ERROR_SILENT, /* return -1 */
} error_action; } error_action;
}; };