MCPcopy Create free account
hub / github.com/git/git / stream_object_signature

Function stream_object_signature

object-file.c:114–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114int stream_object_signature(struct repository *r,
115 struct odb_read_stream *st,
116 const struct object_id *oid)
117{
118 struct object_id real_oid;
119 struct git_hash_ctx c;
120 char hdr[MAX_HEADER_LEN];
121 int hdrlen;
122
123 /* Generate the header */
124 hdrlen = format_object_header(hdr, sizeof(hdr), st->type, st->size);
125
126 /* Sha1.. */
127 r->hash_algo->init_fn(&c);
128 git_hash_update(&c, hdr, hdrlen);
129 for (;;) {
130 char buf[1024 * 16];
131 ssize_t readlen = odb_read_stream_read(st, buf, sizeof(buf));
132
133 if (readlen < 0) {
134 odb_read_stream_close(st);
135 return -1;
136 }
137 if (!readlen)
138 break;
139 git_hash_update(&c, buf, readlen);
140 }
141 git_hash_final_oid(&real_oid, &c);
142 return !oideq(oid, &real_oid) ? -1 : 0;
143}
144
145/*
146 * Map and close the given loose object fd. The path argument is used for

Callers 2

verify_packfileFunction · 0.85
parse_object_with_flagsFunction · 0.85

Calls 6

format_object_headerFunction · 0.85
git_hash_updateFunction · 0.85
odb_read_stream_readFunction · 0.85
odb_read_stream_closeFunction · 0.85
git_hash_final_oidFunction · 0.85
oideqFunction · 0.85

Tested by

no test coverage detected