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

Function cmp_record_to_refname

refs/packed-backend.c:340–356  ·  view source on GitHub ↗

* Compare a snapshot record at `rec` to the specified NUL-terminated * refname. */

Source from the content-addressed store, hash-verified

338 * refname.
339 */
340static int cmp_record_to_refname(const char *rec, const char *refname,
341 int start, const struct snapshot *snapshot)
342{
343 const char *r1 = rec + snapshot_hexsz(snapshot) + 1;
344 const char *r2 = refname;
345
346 while (1) {
347 if (*r1 == '\n')
348 return *r2 ? -1 : 0;
349 if (!*r2)
350 return start ? 1 : -1;
351 if (*r1 != *r2)
352 return (unsigned char)*r1 < (unsigned char)*r2 ? -1 : +1;
353 r1++;
354 r2++;
355 }
356}
357
358/*
359 * `snapshot->buf` is not known to be sorted. Check whether it is, and

Callers 1

Calls 1

snapshot_hexszFunction · 0.85

Tested by

no test coverage detected