Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
object_id.cocci: match only expressions of type 'struct object_id'
Most of our semantic patches in 'contrib/coccinelle/object_id.cocci' turn calls of SHA1-specific functions into calls of their corresponding object_id counterparts, e.g. sha1_to_hex() to oid_to_hex(). These semantic patches look something like this: @@ expression E1; @@ - sha1_to_hex(E1.hash) + oid_to_hex(&E1) and match the access to the 'hash' field in any data type, not only in 'struct object_id', and, consquently, can produce wrong transformations. Case in point is the recent hash function transition patch "rerere: convert to use the_hash_algo" , which, among other things, renamed 'struct rerere_dir's 'sha1' field to 'hash', and then 'make coccicheck' started to suggest the following wrong transformations for 'rerere.c' : - return sha1_to_hex(id->collection->hash); + return oid_to_hex(id->collection); and - DIR *dir = opendir(git_path("rr-cache/%s", sha1_to_hex(rr_dir->hash))); + DIR *dir = opendir(git_path("rr-cache/%s", oid_to_hex(rr_dir))); Avoid such wrong transformations by tightening semantic patches in 'object_id.cocci' to match only type of or pointers to 'struct object_id'.  https://email@example.com/  https://travis-ci.org/git/git/jobs/440463476#L580 Signed-off-by: SZEDER Gábor <firstname.lastname@example.org> Signed-off-by: brian m. carlson <email@example.com> Signed-off-by: Junio C Hamano <firstname.lastname@example.org>
- Loading branch information
Showing with 63 additions and 54 deletions.