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

Re: [PATCH] dir.c: fix comments to agree with argument name

From
Jeff King <peff@peff.net>
Date
Oct 15, 2020, 19:41 UTC
Message-ID
<20201015194158.GA1490964@coredump.intra.peff.net>
In-Reply-To
<xmqqk0vrfi1r.fsf@gitster.c.googlers.com>
On Thu, Oct 15, 2020 at 11:41:36AM -0700, Junio C Hamano wrote:
Show 17 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> >> - * If "ss" is not NULL, compute SHA-1 of the exclude file and fill
> >> + * If "oid_stat" is not NULL, compute SHA-1 of the exclude file and fill
> >
> > Makes sense. This changed as part of 4b33e60201 (dir: convert struct
> > sha1_stat to use object_id, 2018-01-28). Perhaps it would likewise make
> > sense to stop saying "SHA-1" here, and just say "hash" (or even "object
> > id", though TBH I think the fact that the hash is the same as an
> > object-id is largely an implementation detail).
> 
> I do not quite get your "though TBH", though.  I do agree with you
> that it is an implementation detail that an object is named after
> the hash of its contents, so saying "compute object name" probably
> makes sense in more context than "compute hash" outside the narrow
> parts of the code that actually implements how object names are
> computed.  So I would have expected "because TBH", not "though TBH".
Sorry, I was just confused.

The implementation detail I meant is that we are using a "struct object_id" in the oid_stat type (and also that "oid_stat" is likewise exposing too much). I thought this was another version of our stat_validity, where we are checking quickly to see if a random file that is not necessarily part of the working tree has been updated.

And indeed, we do use it that way for files like .git/info/exclude, where having an "object_id" is really irrelevant. But we also use it for checking the validity of tracked files, where we populate it from an actual blob (see dir.c:do_read_blob).

So it is actually reasonable to expose that in the name, and to think about it as an object_id.

> Anyway.  Nipunn, can you fix both of them in the same commit, as
> they are addressing a problem from the same cause (i.e. we are no
> longer SHA-1 centric).
The v2 that Nipunn sent with "oid" in the comment looks good to me.
-Peff
Previous: Nipunn KoorapatiNext: Junio C Hamano
Message 5 of 8 in “dir.c: fix comments to agree with argument name”
  1. dir.c: fix comments to agree with argument nameNipunn Koorapati via GitGitGadget, Oct 15, 2020
  2. Jeff KingOct 15, 2020
  3. Junio C HamanoOct 15, 2020
  4. Nipunn KoorapatiOct 15, 2020
  5. Jeff KingOct 15, 2020
  6. Junio C HamanoOct 15, 2020
  7. Nipunn KoorapatiOct 16, 2020
  8. dir.c: fix comments to agree with argument nameNipunn Koorapati via GitGitGadget, Oct 15, 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.