diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-09-12 11:05:08 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-12 11:05:08 -0700 |
commit | 40e94ca19adf00caa3d19a199b9b0a6079d12a3a (patch) | |
tree | 3b4a451e3e4ba2c9345378ef7e3f55930b632ede /object.c | |
parent | 5ba9a93b39bef057be54ecf7933386a582981625 (diff) | |
parent | f99b7af661f89865f918e52223a3bdaf312a0de0 (diff) | |
download | git-40e94ca19adf00caa3d19a199b9b0a6079d12a3a.tar.gz git-40e94ca19adf00caa3d19a199b9b0a6079d12a3a.tar.xz |
Merge branch 'js/fsck-tag-validation' into HEAD
* js/fsck-tag-validation:
Make sure that index-pack --strict checks tag objects
Add regression tests for stricter tag fsck'ing
fsck: check tag objects' headers
Make sure fsck_commit_buffer() does not run out of the buffer
fsck_object(): allow passing object data separately from the object itself
Refactor type_from_string() to allow continuing after detecting an error
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -33,13 +33,20 @@ const char *typename(unsigned int type) return object_type_strings[type]; } -int type_from_string(const char *str) +int type_from_string_gently(const char *str, ssize_t len, int gentle) { int i; + if (len < 0) + len = strlen(str); + for (i = 1; i < ARRAY_SIZE(object_type_strings); i++) - if (!strcmp(str, object_type_strings[i])) + if (!strncmp(str, object_type_strings[i], len)) return i; + + if (gentle) + return -1; + die("invalid object type \"%s\"", str); } |