diff options
author | Vicent Martà <vicent@github.com> | 2012-11-13 14:59:18 -0800 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2012-11-13 14:59:18 -0800 |
commit | 513e794ef47363b8900816a9b141b3eae81eb83e (patch) | |
tree | 7125079999fa0984e4395666e6637117b902a590 /src/util.c | |
parent | f6c18dda048ae3332d60468c34c4fd7d1aa67f1e (diff) | |
parent | 0da81d2b39290fe4d444953acb6d68795ed1ef42 (diff) | |
download | libgit2-513e794ef47363b8900816a9b141b3eae81eb83e.tar.gz |
Merge pull request #1068 from carlosmn/config-empty-value
Deal with empty and nonexsitent values in config
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/util.c b/src/util.c index 0a82ccea6..7f5043817 100644 --- a/src/util.c +++ b/src/util.c @@ -432,12 +432,8 @@ int git__strcmp_cb(const void *a, const void *b) int git__parse_bool(int *out, const char *value) { /* A missing value means true */ - if (value == NULL) { - *out = 1; - return 0; - } - - if (!strcasecmp(value, "true") || + if (value == NULL || + !strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "on")) { *out = 1; @@ -445,7 +441,8 @@ int git__parse_bool(int *out, const char *value) } if (!strcasecmp(value, "false") || !strcasecmp(value, "no") || - !strcasecmp(value, "off")) { + !strcasecmp(value, "off") || + value[0] == '\0') { *out = 0; return 0; } |