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

Function parse_oid_prefix

object-name.c:232–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static int parse_oid_prefix(const char *name, int len,
233 const struct git_hash_algo *algo,
234 char *hex_out,
235 struct object_id *oid_out)
236{
237 for (int i = 0; i < len; i++) {
238 unsigned char c = name[i];
239 unsigned char val;
240 if (c >= '0' && c <= '9') {
241 val = c - '0';
242 } else if (c >= 'a' && c <= 'f') {
243 val = c - 'a' + 10;
244 } else if (c >= 'A' && c <='F') {
245 val = c - 'A' + 10;
246 c -= 'A' - 'a';
247 } else {
248 return -1;
249 }
250
251 if (hex_out)
252 hex_out[i] = c;
253 if (oid_out) {
254 if (!(i & 1))
255 val <<= 4;
256 oid_out->hash[i >> 1] |= val;
257 }
258 }
259
260 if (hex_out)
261 hex_out[len] = '\0';
262 if (oid_out)
263 oid_out->algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN;
264
265 return 0;
266}
267
268static int init_object_disambiguation(struct repository *r,
269 const char *name, int len,

Callers 2

repo_for_each_abbrevFunction · 0.85

Calls 1

hash_algo_by_ptrFunction · 0.85

Tested by

no test coverage detected