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

Function find_reused_offset

builtin/pack-objects.c:1076–1095  ·  view source on GitHub ↗

* Binary search to find the chunk that "where" is in. Note * that we're not looking for an exact match, just the first * chunk that contains it (which implicitly ends at the start * of the next chunk. */

Source from the content-addressed store, hash-verified

1074 * of the next chunk.
1075 */
1076static off_t find_reused_offset(off_t where)
1077{
1078 int lo = 0, hi = reused_chunks_nr;
1079 while (lo < hi) {
1080 int mi = lo + ((hi - lo) / 2);
1081 if (where == reused_chunks[mi].original)
1082 return reused_chunks[mi].difference;
1083 if (where < reused_chunks[mi].original)
1084 hi = mi;
1085 else
1086 lo = mi + 1;
1087 }
1088
1089 /*
1090 * The first chunk starts at zero, so we can't have gone below
1091 * there.
1092 */
1093 assert(lo);
1094 return reused_chunks[lo-1].difference;
1095}
1096
1097static void write_reused_pack_one(struct packed_git *reuse_packfile,
1098 size_t pos, struct hashfile *out,

Callers 1

write_reused_pack_oneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected