Subject: Re: [QUESTION] how to diff one blob with nothing

From: Junio C Hamano <[email-masked]>
Date: Wed, 26 Jul 2023 11:23:52 -0700

ZheNing Hu <[email-masked]> writes:

>> If you haven't created one, of course it would fail.  It should help
>> to do
>>
>>     $ git hash-object -w --stdin </dev/null
>>
>> before running
>>
>>     $ git diff 00750edc e69de29bb
>>
>
> This is a viable solution, but it's a bit ugly since a read-only "diff"
> requires ”write“ an empty blob.

If you do not even have an empty blob, you have no business
comparing some other blobs you have with it, do you?

If you do not have a file with a single line "hello, world\n" (that
hashes to 4b5fa63702dd96796042e92787f464e28f09f17d if written in a
blob), then you cannot do "git diff 4b5fa637" with anything and
expect it to work.  It is the same thing.

Besides, if you _know_ you want to compare a blob X to emptyness,
you are better of doing "git cat-file blob X" in the first place.