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

Re: [PATCH v9 1/5] sha1_file: support reading from a loose object of unknown type

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 29, 2015, 19:35 UTC
Message-ID
<xmqq383i6849.fsf@gitster.dls.corp.google.com>
In-Reply-To
<554119F6.5010900@gmail.com>
karthik nayak <karthik.188@gmail.com> writes:
Show 16 quoted lines
> On 04/29/2015 08:19 PM, Junio C Hamano wrote:
>> Karthik Nayak <karthik.188@gmail.com> writes:
>>
>>> Update sha1_loose_object_info() to optionally allow it to read
>>> from a loose object file of unknown/bogus type; as the function
>>> usually returns the type of the object it read in the form of enum
>>> for known types, add an optional "typename" field to receive the
>>> name of the type in textual form and a flag to indicate the reading
>>> of a loose object file of unknown/bogus type.
>>>
>>> Add parse_sha1_header_extended() which acts as a wrapper around
>>> parse_sha1_header() allowing more information to be obtained.
>>
>> Thanks.  This mostly looks good modulo a nit.
>
> Sorry didn't get what you meant by "modulo a nit.".

"nit" as in "Nit-pick"; a small imperfection that may need to be corrected (such as the "what if we saw failure earlier and 'status' already had a value?" issue).

Show 18 quoted lines
>> It is a good trade-off between complexity and efficiency.  The
>> complexity is isolated as the function is file-scope-static and it
>> is perfectly fine to force the callers to be extra careful.
>>
>> But this suggests that the patch to add tests should try at least
>> two, preferably three, kinds of test input.  A bogus type that needs
>> a header longer than the caller's fixed buffer, a bogus type whose
>> header would fit within the fixed buffer, and optionally a correct
>> type whose header should always fit within the fixed buffer.
>
> Yes it is a tradeoff, and it is complex as in the user has to check
> the strbuf provided to see if its been used. But this like you said I
> guess its a good tradeoff.
> About the three tests, My patch checks "a bogus type whose header
> would fit within the fixed buffer" and "correct type whose header
> should always fit within the fixed buffer" but will write a test to
> check "A bogus type that needs a header longer than the caller's fixed
> buffer"
Yup. Please do so; that would make the test coverage more complete.
Previous: karthik nayakNext: karthik nayak
Message 5 of 17 in “cat-file: teach cat-file a '--allow-unkown-type' option”
  1. 0/5 cat-file: teach cat-file a '--allow-unkown-type' optionkarthik nayak, Apr 29, 2015
  2. 1/5 sha1_file: support reading from a loose object of unknown typeKarthik Nayak, Apr 29, 2015
  3. Junio C HamanoApr 29, 2015
  4. karthik nayakApr 29, 2015
  5. Junio C HamanoApr 29, 2015
  6. karthik nayakApr 30, 2015
  7. 2/5 cat-file: make the options mutually exclusiveKarthik Nayak, Apr 29, 2015
  8. 3/5 cat-file: teach cat-file a '--allow-unknown-type' optionKarthik Nayak, Apr 29, 2015
  9. Junio C HamanoApr 29, 2015
  10. karthik nayakApr 29, 2015
  11. Phil HordApr 29, 2015
  12. karthik nayakApr 29, 2015
  13. Junio C HamanoApr 29, 2015
  14. 5/5 t1006: add tests for git cat-file --allow-unkown-typeKarthik Nayak, Apr 29, 2015
  15. Eric SunshineApr 29, 2015
  16. 4/5 cat-file: add documentation for '--allow-unkown-type' option.Karthik Nayak, Apr 29, 2015
  17. Eric SunshineApr 29, 2015

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.