Patrick Steinhardt <ps@xxxxxx> writes: >> +static int check_collision(const char *filename_a, const char *filename_b) >> +{ >> ... >> + return ret; >> +} >> + >> /* >> * Move the just written object into its final resting place. >> */ > > This function compares the exact contents, but isn't that wrong? The > contents may differ even though the object is the same because the > object hash is derived from the uncompressed data, whereas we store > compressed data on disk. Very true. So check_collision is *not* a good name for this helper function. For .pack files, a collision means two resulting files have the identical contents, so the above function, perhaps renamed to "compare_files()" or something, is a very appropriate helper to detect a collision once you get two files that claim to be the same .pack file. For loose object files, a collision means the contents before compression are the same, so if we wanted to check collisions within the same framework, we'd need "compare_files_after_inflating()" or something, that opens both files and compare their contents while "inflating" via zlib. Thanks.