git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] merge-recursive: remove unnecessary oid_eq function

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 2, 2020, 18:35 UTC
Message-ID
<xmqqtv5demg4.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<c653a9b8d3863b3484eff224bbfbde65c250eaf0.1577856057.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 18 quoted lines
> From: Elijah Newren <newren@gmail.com>
>
> 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 ;-)

Previous: Elijah Newren via GitGitGadgetNext: Johannes Schindelin
Message 3 of 4 in “merge-recursive: remove unnecessary oid_eq function”
  1. 0/1 merge-recursive: remove unnecessary oid_eq functionElijah Newren via GitGitGadget, Jan 1, 2020
  2. 1/1 merge-recursive: remove unnecessary oid_eq functionElijah Newren via GitGitGadget, Jan 1, 2020
  3. Junio C HamanoJan 2, 2020
  4. Johannes SchindelinJan 2, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.