From: Kevin <ikke@ikke.info>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>
Subject: Re: Fwd: possible Improving diff algoritm
Date: Wed, 12 Dec 2012 20:30:01 +0100 [thread overview]
Message-ID: <CAO54GHANKuv_+S-FJzrTfeFyiXcKDbm5hLGdADQ7GVMh7jEMxw@mail.gmail.com> (raw)
In-Reply-To: <7vvcc73yzh.fsf@alter.siamese.dyndns.org>
Yeah, I didn't mention it, but I didn't think it was doing this wrong
in a systematic way. I only wondered if there was some kind of
heuristic that could improve the cases where it goes wrong, without
affecting the cases where it would do it right.
I know this is not an easy problem, lest it would already been fixed.
On Wed, Dec 12, 2012 at 7:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Kevin <ikke@ikke.info> writes:
>
>> Regularly I notice that the diffs that are provided (through diff, or
>> add -p) tend to disconnect changes that belong to each other and
>> report lines being changed that are not changed.
>>
>> An example for this is:
>>
>> /**
>> + * Default parent
>> + *
>> + * @var int
>> + * @access protected
>> + * @index
>> + */
>> + protected $defaultParent;
>> +
>> + /**
>>
>> I understand this is a valid view of what is changed, but not a very
>> logical view from the point of the user.
>>
>> I wondered if there is a way to improve this, or would that have other
>> consequences.
>
> I think your example shows a case where the end of the pre-context
> matches the end of the added text in the hunk, and it appears it may
> produce a better result if you shift the hunk up. But I think that
> works only half the time. Imagine:
>
> @@ -K,L +M,N @@
> }
>
> +void new_function(void)
> +{
> + printf("hello, world.\n");
> +}
> +
> void existing_one(void)
> {
> printf("goodbye, world.\n");
>
> Here the end of the pre-context matches the end of the added lines,
> but it will produce worse result if you blindly apply the "shift the
> hunk up" trick:
>
> ... what was before the } we saw in the precontext ...
> +}
> +
> +void new_function(void)
> +{
> + printf("hello, world.\n");
> }
>
> void existing_one(void)
>
> So I think with s/Regularly/About half the time/, your observation
> above is correct.
>
> I think the reason you perceived this as "Regularly" is that you do
> not notice nor appreciate it when things go right (half the time),
> but you tend to notice and remember only when a wrong side happened
> to have been picked (the other half).
next prev parent reply other threads:[~2012-12-12 19:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAO54GHC4AXQO1MbU2qXMdcDO5mtUFhrXfXND5evc93kQhNfCrw@mail.gmail.com>
2012-12-12 15:03 ` Fwd: possible Improving diff algoritm Kevin
2012-12-12 18:29 ` Junio C Hamano
2012-12-12 18:48 ` Brian J. Murrell
2012-12-12 19:30 ` Kevin [this message]
2012-12-12 20:29 ` Junio C Hamano
2012-12-12 21:40 ` Morten Welinder
2012-12-12 21:53 ` Junio C Hamano
2012-12-12 22:34 ` Andrew Ardill
2012-12-12 23:32 ` Javier Domingo
2012-12-12 23:43 ` Junio C Hamano
2012-12-12 23:49 ` Javier Domingo
2012-12-13 0:00 ` Michael Haggerty
2012-12-13 1:55 ` Morten Welinder
2012-12-13 4:58 ` Geert Bosch
2012-12-13 6:26 ` Junio C Hamano
2012-12-14 12:20 ` Javier Domingo
2012-12-14 22:29 ` Bernhard R. Link
2012-12-15 12:16 ` Javier Domingo
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAO54GHANKuv_+S-FJzrTfeFyiXcKDbm5hLGdADQ7GVMh7jEMxw@mail.gmail.com \
--to=ikke@ikke.info \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).