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

Re: [PATCH 6/7] read-cache: refuse to create index referring to external objects

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 25, 2013, 19:00 UTC
Message-ID
<7vpq0t3x60.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CACsJy8C3tLOHCK4Qc--W630do0M=xLKSMoYUxxv2_GDaUXaRww@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
> .... Even
> when cache-tree is not involved, I do not want the index to point to
> an non-existing SHA-1 ("git diff --cached" may fail next time, for
> example).

I think we have tests that explicitly add SHA-1 that names an object that does not exist to the index and check failures; you may have to think what to do with them.

Show 12 quoted lines
>> This is a tangent, but in addition, you may want to add an even
>> narrower variant that checks the same but ignoring _all_ alternate
>> object databases, "external" or not:
>>
>>         int has_sha1_file_local(const unsigned char *sha1);
>>
>> That may be useful if we want to later make the alternate safer to
>> use; instead of letting the codepath to create an object ask
>> has_sha1_file() to see if it already exists and refrain from writing
>> a new copy, we switch to ask has_sha1_file_locally() and even if an
>> alternate object database we borrow from has it, we keep our own
>> copy in our repository.

This is not a tangent, but if you want to go this "forbid making our repository depend on objects we do not have but we know about after we peek submodule odb" route [*1*], write_sha1_file() needs to be told about has_sha1_file_proper(). We may "git add" a new blob in the superproject, the blob may not yet exist in *our* repository, but may happen to already exist in the submodue odb. In such a case, write_sha1_file() has to write that blob in our repository, without the existing has_sha1_file() check bypassing it. Otherwise our attempt to create a tree that contains that blob will fail, saying that the blob only seems to exist to us via submodule odb but not in our repository.

[Footnote]

*1* which I do not necessarily agree with---I am in favor of getting rid of add_submodule_odb() to fix these issues at the root cause of them.

Previous: Duy NguyenNext: Duy Nguyen
Message 9 of 21 in “sha1_file: keep track of where an SHA-1 object comes from”
  1. 1/7 sha1_file: keep track of where an SHA-1 object comes fromNguyễn Thái Ngọc Duy, Jan 24, 2013
  2. 2/7 sha1_file: separate alt object db from own repos and submodules'sNguyễn Thái Ngọc Duy, Jan 24, 2013
  3. 3/7 sha1_file: refuse to write commits referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  4. 4/7 sha1_file: refuse to write trees referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  5. 5/7 sha1_file: refuse to write tags referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  6. 6/7 read-cache: refuse to create index referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  7. Junio C HamanoJan 24, 2013
  8. Duy NguyenJan 25, 2013
  9. Junio C HamanoJan 25, 2013
  10. Duy NguyenJan 28, 2013
  11. Junio C HamanoJan 28, 2013
  12. Duy NguyenJan 28, 2013
  13. Junio C HamanoJan 28, 2013
  14. Duy NguyenJan 28, 2013
  15. Junio C HamanoJan 28, 2013
  16. Duy NguyenJan 28, 2013
  17. 7/7 refs: do not update ref(log) referring to external objectsNguyễn Thái Ngọc Duy, Jan 24, 2013
  18. Junio C HamanoJan 24, 2013
  19. Duy NguyenJan 25, 2013
  20. Junio C HamanoJan 25, 2013
  21. Duy NguyenJan 25, 2013

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.