git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
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 23:42:15 -0500	[thread overview]
Message-ID: <20101220044214.GA5942@sigill.intra.peff.net> (raw)
In-Reply-To: <7vr5dddvrk.fsf@alter.siamese.dyndns.org>

On Sun, Dec 19, 2010 at 06:26:55PM -0800, Junio C Hamano wrote:

> 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?

I'm not sure returning the empty string for a textconv is the right
solution. I am inclined to say that trying to textconv a
!DIFF_FILE_VALID is simply an error. More on that in a second.

If we were to do anything else, I would think it would be to feed "" to
the textconv filter, in case it wanted to do something magical for the
create/delete case. For example, imagine a textconv filter which turned
a string of bytes like "foo" into a length plus set of converted bytes,
like "3: FOO". You would want the /dev/null case to turn into "0: ".

Now, this is obviously a ridiculous toy case. I have no idea if anyone
would want to do something like that. So far most people have been happy
with /dev/null never being textconv'd, and always looking like the empty
string. Moreover, even if somebody did want this behavior, 99% of the
other filters _wouldn't_ want the behavior. Because programs like
odt2txt or exiftool that people _do_ use for textconv filters do not
want to be fed /dev/null; they will signal an error.

So that is my "if we wanted it to do something useful, this is what it
would do" case, and I don't see any real-world evidence that anybody
wants that. Now on to being defensive.

What we are defending against is a caller marking something as
to-be-textconv'd, even though it is !DIFF_FILE_VALID. But what did the
caller want? One sensible behavior is what I described above. Or maybe
they did just want the empty string. Or more likely, it is simply a bug
in the diff code. Since we haven't defined the semantics, I would much
rather loudly scream "BUG!" than paper over it by returning what we
guess they would have wanted (which may generate subtly wrong results).
And then we can think about that use case and decide what the semantics,
if any, should be.

So I stand by my thought that it should die(). But I don't think there
_are_ any such bugs currently, so it probably doesn't matter much either
way. I can live with "return 0", or even just leaving it alone.

-Peff

  reply	other threads:[~2010-12-20  4:42 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
2010-12-20  4:42       ` Jeff King [this message]
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=20101220044214.GA5942@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=axel.bonnet@ensimag.imag.fr \
    --cc=clement.poulain@ensimag.imag.fr \
    --cc=diane.gasselin@ensimag.imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kirr@landau.phys.spbu.ru \
    /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).