Thread (2 messages) flat view 2 messages, 2 authors, 2017-10-06

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

From: René Scharfe <hidden>
Date: 2017-10-06 16:21:27

Am 06.10.2017 um 04:23 schrieb Junio C Hamano:
René Scharfe [off-list ref] writes:
quoted
+	blob_bin=$(echo $blob | hex2oct) &&
+	tree=$(
+		printf "40000 dir\0${blob_bin}100644 file\0${blob_bin}" |
Wow, that's ... cute.
quoted
+		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é
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help