diff options
| author | Ben Straub <bstraub@github.com> | 2012-06-05 12:52:44 -0700 |
|---|---|---|
| committer | Ben Straub <bstraub@github.com> | 2012-06-05 12:52:44 -0700 |
| commit | 56a5000d580ef5c9605bc9076610b5af9aa67518 (patch) | |
| tree | 4026c8333991fbe221a17b5d16e5e4b52f66cb20 /src/util.c | |
| parent | e267c9fc1a4910d1081e97b4d7a411658ddc0def (diff) | |
| parent | 01dbe273c9b6f86a613b67cee27212cf4bacf4c0 (diff) | |
| download | libgit2-56a5000d580ef5c9605bc9076610b5af9aa67518.tar.gz | |
Merge branch 'development' into rev-parse
Conflicts:
src/util.h
tests-clar/refs/branches/listall.c
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 9fd5f286c..ce770203a 100644 --- a/src/util.c +++ b/src/util.c @@ -411,3 +411,27 @@ int git__strcmp_cb(const void *a, const void *b) return strcmp(stra, strb); } + +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") || + !strcasecmp(value, "yes") || + !strcasecmp(value, "on")) { + *out = 1; + return 0; + } + if (!strcasecmp(value, "false") || + !strcasecmp(value, "no") || + !strcasecmp(value, "off")) { + *out = 0; + return 0; + } + + return -1; +} |
