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

Re: [PATCH 2/2] sha1-lookup: fix handling of duplicates in sha1_pos()

From
Jeff King <peff@peff.net>
Date
Oct 1, 2014, 12:33 UTC
Message-ID
<20141001123343.GA10772@peff.net>
In-Reply-To
<542BE114.9070300@web.de>
On Wed, Oct 01, 2014 at 01:10:12PM +0200, René Scharfe wrote:
Show 5 quoted lines
> >I wonder if it is worth adding a test (you test only that "not found"
> >produces a negative index, but not which index). Like:
> 
> api-sha1-array.txt says about sha1_array_lookup: "If not found, returns a
> negative integer", and that's what the test checks.

Hmm. I do not recall intentionally leaving the value unspecified; I think it is more that I was simply not thorough when writing the documentation. That being said...

> I actually like that the value is not specified for that case because no
> existing caller actually uses it and it leaves room to implement the
> function e.g. using bsearch(3).

Yeah, if no callers actually care right now, that is a reasonable argument for leaving the exact return value unspecified (and testing only what the documentation claims).

> I agree that adding a "lookup non-existing entry with duplicates" test would
> make t0064 more complete, though.
Agreed.
-Peff
Previous: René ScharfeNext: Eric Sunshine
Message 5 of 9 in “sha1-array: add test-sha1-array and basic tests”
  1. 1/2 sha1-array: add test-sha1-array and basic testsRené Scharfe, Oct 1, 2014
  2. 2/2 sha1-lookup: fix handling of duplicates in sha1_pos()René Scharfe, Oct 1, 2014
  3. Jeff KingOct 1, 2014
  4. René ScharfeOct 1, 2014
  5. Jeff KingOct 1, 2014
  6. Eric SunshineOct 1, 2014
  7. Eric SunshineOct 1, 2014
  8. René ScharfeOct 1, 2014
  9. Jeff KingOct 1, 2014

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.