diff -U0 occasionally misses a chance to make empty lines context [was: Re: [BUG] difference of info from diff and blame]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]