diff options
author | Russell Belfer <rb@github.com> | 2014-05-12 14:38:39 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-15 14:11:19 -0700 |
commit | 575f107704255254f52d197240d55f2030af0454 (patch) | |
tree | af5149788297f3e9ec17992b342a3005eab36e31 /src/util.h | |
parent | 88b1b36dfcc6b406f2b6f21e0e042071984b3b90 (diff) | |
download | libgit2-rb/object-parse-flexibility.tar.gz |
Add lax parsing for commit and tag objectsrb/object-parse-flexibility
This changes the behavior of object parsing for commits and tags
so that even when bad data is found inside the object, we will
continue to try to parse as much of the object as we can. The
existing functions (`git_object_lookup` for example) will still
delete the partially parsed object before returning an error, but
this also adds a new function `git_object_lookup_lax` that will
still return the error, but will also return the object with the
partial data (if we got far enough along in the parsing process to
even create the base object).
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h index 6fb2dc0f4..8d300987f 100644 --- a/src/util.h +++ b/src/util.h @@ -322,6 +322,12 @@ GIT_INLINE(bool) git__iswildcard(int c) return (c == '*' || c == '?' || c == '['); } +GIT_INLINE(bool) git__iseol(const char *ptr, size_t len) +{ + char c = *ptr; + return (c == '\n' || (c == '\r' && len > 1 && *(ptr + 1) == '\n')); +} + /* * Parse a string value as a boolean, just like Core Git does. * |