git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Git List" <git@vger.kernel.org>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Martin Koegler" <martin.koegler@chello.at>
Subject: Re: [PATCH v2] fsck: handle NULL return of lookup_blob() and lookup_tree()
Date: Fri, 6 Oct 2017 18:21:08 +0200	[thread overview]
Message-ID: <954958d2-5d5a-15e0-0e2b-421f859c1227@web.de> (raw)
In-Reply-To: <xmqq8tgpypyl.fsf@gitster.mtv.corp.google.com>

Am 06.10.2017 um 04:23 schrieb Junio C Hamano:
> 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é

      reply	other threads:[~2017-10-06 16:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-01 14:45 [PATCH] tag: avoid NULL pointer arithmetic René Scharfe
2017-10-02  4:13 ` Junio C Hamano
2017-10-02  5:08 ` Jeff King
2017-10-02 13:06   ` René Scharfe
2017-10-02 19:23     ` Jeff King
2017-10-03 10:22 ` SZEDER Gábor
2017-10-03 12:51   ` René Scharfe
2017-10-03 13:47     ` [PATCH] fsck: check results of lookup_blob() and lookup_tree() for NULL René Scharfe
2017-10-04  4:00       ` Junio C Hamano
2017-10-05 19:41         ` René Scharfe
2017-10-05 19:41       ` [PATCH v2] fsck: handle NULL return of lookup_blob() and lookup_tree() René Scharfe
2017-10-06  2:23         ` Junio C Hamano
2017-10-06 16:21           ` René Scharfe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=954958d2-5d5a-15e0-0e2b-421f859c1227@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin.koegler@chello.at \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).