From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Kirill Smelkov" <kirr@landau.phys.spbu.ru>,
git@vger.kernel.org, "Axel Bonnet" <axel.bonnet@ensimag.imag.fr>,
"Clément Poulain" <clement.poulain@ensimag.imag.fr>,
"Diane Gasselin" <diane.gasselin@ensimag.imag.fr>
Subject: Re: [PATCH 2/2] fill_textconv(): Don't get/put cache if sha1 is not valid
Date: Sun, 19 Dec 2010 18:26:55 -0800 [thread overview]
Message-ID: <7vr5dddvrk.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20101218161337.GB18643@sigill.intra.peff.net> (Jeff King's message of "Sat\, 18 Dec 2010 11\:13\:37 -0500")
Jeff King <peff@peff.net> writes:
> PS It is a little disturbing that in fill_textconv, we handle
> case (1), !DIFF_FILE_VALID for the non-textconv case, but not so for the
> textconv case. I think we are OK, as get_textconv will never load a
> textconv driver for a !DIFF_FILE_VALID filespec, so we always follow the
> non-textconv codepath in that case. But I am tempted to do this just to
> be more defensive:
FILE_VALID() is about "does that side have a blob there, or is this
create/delete diff?", so the caller should be handling this properly as
you said, but your fill_textconv() already prepares for the case where the
caller for some reason calls this function with "no blob on this side" and
returns an empty string (see the precontext of your patch).
I think it is fine to be defensive to prepare for such a case, but then
dying like this patch does is inconsistent. Perhaps we should move the
new check higher and remove the *outbuf = "" while at it?
> diff --git a/diff.c b/diff.c
> index b0ee213..5320849 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4404,22 +4404,25 @@ size_t fill_textconv(struct userdiff_driver *driver,
> if (!driver || !driver->textconv) {
> if (!DIFF_FILE_VALID(df)) {
> *outbuf = "";
> return 0;
> }
> if (diff_populate_filespec(df, 0))
> die("unable to read files to diff");
> *outbuf = df->data;
> return df->size;
> }
>
> + if (!DIFF_FILE_VALID(df))
> + die("BUG: attempt to textconv an invalid filespec");
> +
next prev parent reply other threads:[~2010-12-20 2:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-18 14:54 [PATCH 1/2] t/t8006: Demonstrate blame is broken when cachetextconv is on Kirill Smelkov
2010-12-18 14:54 ` [PATCH 2/2] fill_textconv(): Don't get/put cache if sha1 is not valid Kirill Smelkov
2010-12-18 16:13 ` Jeff King
2010-12-18 20:55 ` Kirill Smelkov
2010-12-19 3:23 ` Junio C Hamano
2010-12-19 12:10 ` Kirill Smelkov
2010-12-20 2:41 ` Junio C Hamano
2010-12-20 4:46 ` Jeff King
2010-12-20 19:28 ` Kirill Smelkov
2010-12-20 2:26 ` Junio C Hamano [this message]
2010-12-20 4:42 ` Jeff King
2010-12-20 8:42 ` Junio C Hamano
2010-12-20 2:32 ` Junio C Hamano
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=7vr5dddvrk.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=axel.bonnet@ensimag.imag.fr \
--cc=clement.poulain@ensimag.imag.fr \
--cc=diane.gasselin@ensimag.imag.fr \
--cc=git@vger.kernel.org \
--cc=kirr@landau.phys.spbu.ru \
--cc=peff@peff.net \
/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).