All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: Semyon Kirnosenko <semyon.kirnosenko@gmail.com>
Cc: <git@vger.kernel.org>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>,
	Davide Libenzi <davidel@xmailserver.org>
Subject: diff -U0 occasionally misses a chance to make empty lines context [was: Re: [BUG] difference of info from diff and blame]
Date: Wed, 12 Jan 2011 11:20:26 +0100	[thread overview]
Message-ID: <201101121120.26724.trast@student.ethz.ch> (raw)
In-Reply-To: <4D2D5E08.9040804@gmail.com>

Ok, so to summarize for late joiners and the new Ccs:

git diff -U0 occasionally gives suboptimal results in hunks like

Semyon Kirnosenko wrote:
> 11.01.2011 16:40, Thomas Rast пишет:
> > @@ -108,11 +123,8 @@ jQuery.event = {
> > -			var handler = element["on" + type ], val,
> > -				fn = jQuery.isFunction( element[ type ] );
> > -
> > -			if ( handler ) {
> > -				// Pass along a fake event
> > -				data.unshift( this.fix({ type: type, target: element }) );
> > -	
> > -				// Trigger the event
> > -				if ( (val = handler.apply( element, data )) !== false )
> > -					this.triggered = true;
> > -			}
> > +			var val, ret, fn = jQuery.isFunction( element[ type ] );
> > +			
> > +			// Pass along a fake event
> > +			data.unshift( this.fix({ type: type, target: element }) );
> > +
> > +			// Trigger the event
> > +			if ( (val = this.handle.apply( element, data )) !== false )
> > +				this.triggered = true;

where two of the whitespace lines are the same and thus could have
been made context.  Oddly enough, this specific line *is* made context
for the default -U3.  This occasionally causes git-blame (which uses
the equivalent of 'git diff -U0' internally) to misattribute blank
lines.  This does *not* affect correctness of the diff, it is just
suboptimal.

My own guess at the problem is

> > I wouldn't be too surprised if it had heuristics that put lines
> > consisting only of whitespace at a lower importance than "actual"
> > lines.

i.e. that it's whitespace-related, and indeed Semyon says

> All cases I have seen were about whitespace lines.

I don't really care, since I haven't seen a single use-case where the
attribution of empty lines matters.  Still, let's at least bring it to
the attention of the people who have worked on libxdiff.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

      reply	other threads:[~2011-01-12 10:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 10:38 [BUG] difference of info from diff and blame Semyon Kirnosenko
2011-01-11 13:40 ` Thomas Rast
2011-01-12  7:53   ` Semyon Kirnosenko
2011-01-12 10:20     ` Thomas Rast [this message]

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=201101121120.26724.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=davidel@xmailserver.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=semyon.kirnosenko@gmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.