git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] fill_textconv(): Don't get/put cache if sha1 is not valid

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 20, 2010, 02:26 UTC
Message-ID
<7vr5dddvrk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20101218161337.GB18643@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 6 quoted lines
> 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?

Show 19 quoted lines
> 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");
> +
Previous: Kirill SmelkovNext: Jeff King
Message 10 of 13 in “t/t8006: Demonstrate blame is broken when cachetextconv is on”
  1. 1/2 t/t8006: Demonstrate blame is broken when cachetextconv is onKirill Smelkov, Dec 18, 2010
  2. 2/2 fill_textconv(): Don't get/put cache if sha1 is not validKirill Smelkov, Dec 18, 2010
  3. Jeff KingDec 18, 2010
  4. Kirill SmelkovDec 18, 2010
  5. Junio C HamanoDec 19, 2010
  6. Kirill SmelkovDec 19, 2010
  7. Junio C HamanoDec 20, 2010
  8. Jeff KingDec 20, 2010
  9. Kirill SmelkovDec 20, 2010
  10. Junio C HamanoDec 20, 2010
  11. Jeff KingDec 20, 2010
  12. Junio C HamanoDec 20, 2010
  13. Junio C HamanoDec 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.