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

Re: [PATCH v2] sha1-file: remove OBJECT_INFO_SKIP_CACHED

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 2, 2020, 21:41 UTC
Message-ID
<xmqqftgxedtk.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20200102201630.180969-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 11 quoted lines
> As a historical note, the function now known as repo_read_object_file()
> was taught the empty tree in 346245a1bb ("hard-code the empty tree
> object", 2008-02-13), and the function now known as oid_object_info()
> was taught the empty tree in c4d9986f5f ("sha1_object_info: examine
> cached_object store too", 2011-02-07). repo_has_object_file() was never
> updated, perhaps due to oversight. The flag OBJECT_INFO_SKIP_CACHED,
> introduced later in dfdd4afcf9 ("sha1_file: teach
> sha1_object_info_extended more flags", 2017-06-26) and used in
> e83e71c5e1 ("sha1_file: refactor has_sha1_file_with_flags", 2017-06-26),
> was introduced to preserve this difference in empty-tree handling, but
> now it can be removed.

I am not 100% sure if the implication of this change is safe to allow us to say "now it can be".

The has_object_file() helper wanted to say "no" when given a non-existing object registered via the pretend_object_file(), presumably because we wanted to allow a use pattern like:

 - prepare an in-core representation of an object we tentatively
   expect, but not absolutely sure, to be necessary.
 - perform operations, using the object data obtained via
   read_object() API, which is capable of yielding data even for
   such "pretend" objects (perhaps we are creating a tentative merge
   parents during a recursive merge).
 - write out final set of objects by enumerating those that do not
   really exist yet (via has_object_file() API).

Teaching about the empty tree to has_object_file() is a good thing (especially because we do not necessarily write an empty tree object to our repositories), but as a collateral damage of doing so, we make such use pattern impossible.

It is not a large loss---the third bullet in the above list can just be made to unconditionally call write_object_file() without filtering with has_object_file() and write_object_file() will apply the right optimization anyway, so it probably is OK.

Will queue.
Thanks.
Previous: Jonathan TanNext: Jeff King
Message 8 of 13 in “sha1-file: remove OBJECT_INFO_SKIP_CACHED”
  1. sha1-file: remove OBJECT_INFO_SKIP_CACHEDJonathan Tan, Dec 30, 2019
  2. Junio C HamanoDec 30, 2019
  3. Jonathan NiederDec 30, 2019
  4. Jonathan TanDec 31, 2019
  5. Jonathan NiederDec 31, 2019
  6. sha1-file: remove OBJECT_INFO_SKIP_CACHEDJonathan Tan, Jan 2, 2020
  7. sha1-file: remove OBJECT_INFO_SKIP_CACHEDJonathan Tan, Jan 2, 2020
  8. Junio C HamanoJan 2, 2020
  9. Jeff KingJan 6, 2020
  10. Jonathan NiederJan 4, 2020
  11. Jeff KingJan 6, 2020
  12. Jonathan NiederJan 6, 2020
  13. Jeff KingJan 7, 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.