From: Junio C Hamano <gitster@pobox.com>
To: ZheNing Hu <adlternative@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [QUESTION] how to diff one blob with nothing
Date: Wed, 26 Jul 2023 11:23:52 -0700 [thread overview]
Message-ID: <xmqqila6cz0n.fsf@gitster.g> (raw)
In-Reply-To: <CAOLTT8R84Zrtpd=j6o2V=Y_uD54XAS5EA7NWHsdfL+XCkD5cqA@mail.gmail.com> (ZheNing Hu's message of "Thu, 27 Jul 2023 02:00:17 +0800")
ZheNing Hu <adlternative@gmail.com> 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.
next prev parent reply other threads:[~2023-07-26 18:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 9:59 [QUESTION] how to diff one blob with nothing ZheNing Hu
2023-07-19 16:15 ` Junio C Hamano
2023-07-26 18:00 ` ZheNing Hu
2023-07-26 18:23 ` Junio C Hamano [this message]
2023-07-27 17:46 ` Taylor Blau
2023-07-28 3:40 ` ZheNing Hu
2023-08-03 5:16 ` ZheNing Hu
2023-08-03 15:24 ` Taylor Blau
2023-08-04 2:28 ` ZheNing Hu
2023-08-04 8:28 ` Christian Couder
2023-08-04 18:34 ` Taylor Blau
2023-08-04 19:00 ` Junio C Hamano
2023-08-05 8:27 ` ZheNing Hu
2023-07-27 17:13 ` Konstantin Khomoutov
2023-07-28 3:35 ` ZheNing Hu
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqila6cz0n.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adlternative@gmail.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).