diff options
Diffstat (limited to 'src/odb.c')
-rw-r--r-- | src/odb.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -752,6 +752,28 @@ int git_odb__read_header_or_object( return 0; } +static git_oid empty_blob = {{ 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1, 0xd6, 0x43, 0x4b, 0x8b, + 0x29, 0xae, 0x77, 0x5a, 0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91 }}; +static git_oid empty_tree = {{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60, + 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04 }}; + +static int hardcoded_objects(git_rawobj *raw, const git_oid *id) +{ + if (!git_oid_cmp(id, &empty_blob)) { + raw->type = GIT_OBJ_BLOB; + raw->len = 0; + raw->data = NULL; + return 0; + } else if (!git_oid_cmp(id, &empty_tree)) { + raw->type = GIT_OBJ_TREE; + raw->len = 0; + raw->data = NULL; + return 0; + } else { + return GIT_ENOTFOUND; + } +} + int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) { size_t i, reads = 0; @@ -765,7 +787,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) if (*out != NULL) return 0; - error = GIT_ENOTFOUND; + error = hardcoded_objects(&raw, id); for (i = 0; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); |