From: Thomas Rast Date: Wed, 12 Jan 2011 10:20:26 GMT Subject: diff -U0 occasionally misses a chance to make empty lines context [was: Re: [BUG] difference of info from diff and blame] Message-ID: <201101121120.26724.trast@student.ethz.ch> 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