Re: [PATCH 1/1] merge-recursive: remove unnecessary oid_eq function
From: Junio C Hamano <hidden>
Date: 2020-01-02 18:35:15
"Elijah Newren via GitGitGadget" [off-list ref] writes:
From: Elijah Newren <redacted> Back when merge-recursive was first introduced in commit 6d297f8137 (Status update on merge-recursive in C, 2006-07-08), it created a sha_eq() function. This function pre-dated the introduction of hashcmp() to cache.h by about a month, but was switched over to using hashcmp() as part of commit 9047ebbc22 (Split out merge_recursive() to merge-recursive.c, 2008-08-12). In commit b4da9d62f9 (merge-recursive: convert leaf functions to use struct object_id, 2016-06-24), sha_eq() was renamed to oid_eq() and its hashcmp() call was switched to oideq(). oid_eq() is basically just a wrapper around oideq() that has some extra checks to protect against NULL arguments or to allow short-circuiting if one of the arguments is NULL. I don't know if any caller ever tried to call with NULL arguments, but certainly none do now which means the extra checks serve no purpose. (Also, if these checks were genuinely useful, then they probably should be added to the main oideq() so all callers could benefit from them.)
Just for some historical yuck values ^W^W entertainment, 6d297f81373:merge-recursive.c shows how the function was called and needed to prepare for NULL inputs. I agree that today's code won't need the "two NULLs are equal, and NULL is never equal to anything" hack. We've come a long way ;-)