config: add git_config_get_max_percent_split_change()

This new function will be used in a following commit to get the value of the "splitIndex.maxPercentChange" config variable. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Feb 27, 2017 at 19:00 UTC 72dcb7b3607e3349ac3367dc804b62ce1556842b
2 files changed +16
cache.h
+1
@@ -1822,6 +1822,7 @@ extern int git_config_get_maybe_bool(const char *key, int *dest);
1822 extern int git_config_get_pathname(const char *key, const char **dest);
1823 extern int git_config_get_untracked_cache(void);
1824 extern int git_config_get_split_index(void);
1825 +extern int git_config_get_max_percent_split_change(void);
1826
1827 /*
1828 * This is a hack for test programs like test-dump-untracked-cache to
config.c
+15
@@ -1719,6 +1719,21 @@ int git_config_get_split_index(void)
1719 return -1; /* default value */
1720 }
1721
1722 +int git_config_get_max_percent_split_change(void)
1723 +{
1724 + int val = -1;
1725 +
1726 + if (!git_config_get_int("splitindex.maxpercentchange", &val)) {
1727 + if (0 <= val && val <= 100)
1728 + return val;
1729 +
1730 + return error(_("splitIndex.maxPercentChange value '%d' "
1731 + "should be between 0 and 100"), val);
1732 + }
1733 +
1734 + return -1; /* default value */
1735 +}
1736 +
1737 NORETURN
1738 void git_die_config_linenr(const char *key, const char *filename, int linenr)
1739 {