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

Re: [PATCH 3/3] improved validation of entry type in mktree

From
JMJosh Micich <josh.micich@gmail.com>
Date
May 14, 2009, 22:46 UTC
Message-ID
<a644352c0905141546w4193d45aq4940e72bbb4bda1c@mail.gmail.com>
In-Reply-To
<7vd4acxkug.fsf@alter.siamese.dyndns.org>
On Wed, May 13, 2009 at 11:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
>> +     struct strbuf p_uq = STRBUF_INIT;
>>       if (line_termination && path[0] == '"') {
>> -             struct strbuf p_uq = STRBUF_INIT;
>
> Why make its lifetime longer even though you do not use it outside of this
> block?
Sorry, no need. Similar confusion cleared up in patch 1.
Show 6 quoted lines
>> +	enum object_type obj_type = sha1_object_info(sha1, NULL);
>> +     if (obj_type < 0) {
>> +             if (!allow_missing) {
>
> This is the other way around; when allow_missing is given you shouldn't
> even consult the object database to read it.
I think mktree should verify the object types for objects that are available.

For example (given that 4b825d is empty tree and e69de2 is empty blob), mktree should reject the following entries:

100644 blob 4b825dc642cb6eb9a060e54bf8d69288fbee4904 foo 040000 tree e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 bar

I don't think the '--missing' option should cause mktree to accept a tree which is clearly invalid.

Furthermore even with '--missing', a tree entry like this should be rejected: 160000 commit e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 foo

Previous: Junio C HamanoNext: Josh Micich
Message 12 of 16 in “Proposed patch for mktree [0/3]”
  1. Josh MicichMay 14, 2009
  2. 1/3 '--missing' option for mktree: re-added strbuf_release(&p_uq), Updated man pageJosh Micich, May 14, 2009
  3. Junio C HamanoMay 14, 2009
  4. Josh MicichMay 14, 2009
  5. 2/3 added --batch option to mktreeJosh Micich, May 14, 2009
  6. Junio C HamanoMay 14, 2009
  7. Josh MicichMay 14, 2009
  8. Sverre RabbelierMay 14, 2009
  9. Josh MicichMay 14, 2009
  10. 3/3 improved validation of entry type in mktreeJosh Micich, May 14, 2009
  11. Junio C HamanoMay 14, 2009
  12. Josh MicichMay 14, 2009
  13. Josh MicichMay 14, 2009
  14. Jakub NarebskiMay 15, 2009
  15. Josh MicichMay 15, 2009
  16. Junio C HamanoMay 15, 2009

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.