git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Nicolas Pitre <nico@cam.org>
Cc: git@vger.kernel.org
Subject: Re: Delitifier broken (Re: diff-core segfault)
Date: Mon, 12 Dec 2005 13:54:49 -0800	[thread overview]
Message-ID: <7vek4igevq.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0512121620380.26663@localhost.localdomain> (Nicolas Pitre's message of "Mon, 12 Dec 2005 16:28:49 -0500 (EST)")

Nicolas Pitre <nico@cam.org> writes:

>> This is not just "diff".  Our deltify code is half-broken, and
>> in the worst case this can corrupt our packs if an empty blob is
>> involved.
>
> I would say involving an empty blob with deltas _is_ the bug in the 
> first place.  Please don't let that happen.

Not all use of delta is to produce a pack.  An empty->empty
delta is a valid two byte \0\0 sequence, and I do not see any
reason to forbid it.  Although using such delta to represent
anything in a pack does *not* make any sense as you say, it
makes other callers simpler if they do not have to check if
from_len and to_len are empty before calling the delta code.
They care about from_len=0 (or to_len=0) case to produce similar
results as from_len=1 (or to_len=1) case and do not care at all
about the produced delta being a useful one for compressed
storage purposes.

> Especially with pack files, an empty blob can be represented with a 
> _single_ byte.  A delta must always be against something else and simply 
> storing the reference for the object the delta is against will always 
> use at least 20 bytes even for empty ones.

True, and the pack code is actually safe.  It punts on NULL
return, so my initial worry about packs turns out to be
unneeded.

> If my opinion is still of any weight I'd strongly vote for the former.  

I ended up doing both ;-).  The call site of diffcore-break was
certainly careless and broken (fixed); I've run git-grep to
check all callers to diff_delta() and the only one that did not
check the return value with NULL was the one that started with
thread.

  reply	other threads:[~2005-12-12 21:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-12 16:29 diff-core segfault Darrin Thompson
2005-12-12 16:56 ` Johannes Schindelin
2005-12-12 18:50 ` Junio C Hamano
2005-12-12 18:59   ` Delitifier broken (Re: diff-core segfault) Junio C Hamano
2005-12-12 21:28     ` Nicolas Pitre
2005-12-12 21:54       ` Junio C Hamano [this message]
2005-12-12 23:31         ` Linus Torvalds
2005-12-13  1:08           ` Junio C Hamano
2005-12-13  1:34             ` Linus Torvalds
2005-12-13  1:41               ` Junio C Hamano
2005-12-13  2:05               ` Linus Torvalds
2005-12-13  2:45                 ` Nicolas Pitre
2005-12-13  3:23                   ` Junio C Hamano
2005-12-12 20:40 ` [PATCH 2/2] diff-delta.c: allow delta with empty blob Junio C Hamano
2005-12-12 21:12   ` Darrin Thompson

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=7vek4igevq.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=nico@cam.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).