What am I missing here?  The assert seemed right as it was.

Table has no duplicate entries.  Right?  Otherwise, `ofs` goes to 20 (overflows) [here](https://github.com/libgit2/libgit2/blob/67591c8cd8d55e6f3218f1a734385c845459e1ff/src/sha1_lookup.c#L104-L106).

And table is sorted, or else a binary search won't work.

With a sorted table, no duplicate entries, and the invariant that `lo < hi`, we know that `memcmp(lo_key, hi_key, 20) < 0` -- that is, they differ at some offset `ofs < 20`, and `lo_key` is the strictly lower one.  `lov` and `hiv` just take the first byte (or two, if available) from `lo_key` and `hi_key` where they differ.  So `lov` really ought to be `<` (not `<=`) `hiv`.

Did you dig into one of the cores here?  Do the other invariants hold?  A unique, sorted table, `ofs < 20`, `memcmp(lo_key, hi_key, 20)<0`?

What's the underlying problem that this assert uncovered?  If you're wrong about how you change the assert, it just masks whatever more-subtle underlying problem got us here.