odb_pack: handle duplicate objects from different packs

This is based on 24634c6fd02b2240e4a93fad70a08220f8fb793a.

This also corrects an issue with error codes being mixed up with the number of found objects.

I haven't added a test for this as I can't figure out how to do anything with `tests-clar/resources/duplicate.git` (git itself says it's not a valid repo). If people find this approach acceptable (and can point me in the right direction on adding objects to `duplicate.git`), I'll try and add a test.