summaryrefslogtreecommitdiff
path: root/src/oid.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-05-12 14:38:39 -0700
committerRussell Belfer <rb@github.com>2014-05-15 14:11:19 -0700
commit575f107704255254f52d197240d55f2030af0454 (patch)
treeaf5149788297f3e9ec17992b342a3005eab36e31 /src/oid.c
parent88b1b36dfcc6b406f2b6f21e0e042071984b3b90 (diff)
downloadlibgit2-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/oid.c')
-rw-r--r--src/oid.c26
1 files changed, 0 insertions, 26 deletions
diff --git a/src/oid.c b/src/oid.c
index b640cadd1..be4d857cf 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -122,32 +122,6 @@ char *git_oid_tostr(char *out, size_t n, const git_oid *oid)
return out;
}
-int git_oid__parse(
- git_oid *oid, const char **buffer_out,
- const char *buffer_end, const char *header)
-{
- const size_t sha_len = GIT_OID_HEXSZ;
- const size_t header_len = strlen(header);
-
- const char *buffer = *buffer_out;
-
- if (buffer + (header_len + sha_len + 1) > buffer_end)
- return -1;
-
- if (memcmp(buffer, header, header_len) != 0)
- return -1;
-
- if (buffer[header_len + sha_len] != '\n')
- return -1;
-
- if (git_oid_fromstr(oid, buffer + header_len) < 0)
- return -1;
-
- *buffer_out = buffer + (header_len + sha_len + 1);
-
- return 0;
-}
-
void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid)
{
char hex_oid[GIT_OID_HEXSZ];