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

Re: [PATCH v2] fsck: handle NULL return of lookup_blob() and lookup_tree()

From
René Scharfe <l.s.r@web.de>
Date
Oct 6, 2017, 16:21 UTC
Message-ID
<954958d2-5d5a-15e0-0e2b-421f859c1227@web.de>
In-Reply-To
<xmqq8tgpypyl.fsf@gitster.mtv.corp.google.com>
Am 06.10.2017 um 04:23 schrieb Junio C Hamano:
Show 19 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>> +	blob_bin=$(echo $blob | hex2oct) &&
>> +	tree=$(
>> +		printf "40000 dir\0${blob_bin}100644 file\0${blob_bin}" |
> 
> Wow, that's ... cute.
> 
>> +		git hash-object -t tree --stdin -w --literally
> 
> Makes me curious why --literally is here.  Even if we let
> check_tree() called from index_mem() by taking the normal path,
> it wouldn't complain the type mismatch, I suspect.  I guess doing it
> this way is a future-proof against check_tree() getting tightened in
> the future, in which case I think it makes sense.
> 
> And for the same reason, hashing "--literally" like this patch does
> is a better solution than using "git mktree", which would have
> allowed us to avoid the hex2oct and instead feed the tree in a bit
> more human-readable way.

git mktree errors out already, complaining about the object type mismatch. But I added "--literally" only accidentally, when I copied the invocation from a few lines up. The test works fine without that flag currently. The flag captures the intent, however, of knowingly building a flawed tree object.

René
Previous: Junio C Hamano
Message 13 of 13 in “tag: avoid NULL pointer arithmetic”
  1. tag: avoid NULL pointer arithmeticRené Scharfe, Oct 1, 2017
  2. Junio C HamanoOct 2, 2017
  3. Jeff KingOct 2, 2017
  4. René ScharfeOct 2, 2017
  5. Jeff KingOct 2, 2017
  6. SZEDER GáborOct 3, 2017
  7. René ScharfeOct 3, 2017
  8. fsck: check results of lookup_blob() and lookup_tree() for NULLRené Scharfe, Oct 3, 2017
  9. Junio C HamanoOct 4, 2017
  10. René ScharfeOct 5, 2017
  11. fsck: handle NULL return of lookup_blob() and lookup_tree()René Scharfe, Oct 5, 2017
  12. Junio C HamanoOct 6, 2017
  13. René ScharfeOct 6, 2017

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.