Re: possible Improving diff algoritm

2012-12-14 Thread Bernhard R. Link
* Javier Domingo javier...@gmail.com [121214 13:20]: I think the idea of being preferable to have a blank line at the end of the added/deleted block is key in this case. For symmetry I'd suggest to make it preferable to have blank lines at the end or the beginning. { old + } + + { + new

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Junio C Hamano
Kevin i...@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 + * + *

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Brian J. Murrell
On 12-12-12 01:29 PM, Junio C Hamano wrote: 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: Yeah. I would not think a blind shift would be appropriate. But I wonder if diff can take

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Kevin
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

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Junio C Hamano
Junio C Hamano gits...@pobox.com writes: Kevin i...@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: /**

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Morten Welinder
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

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Junio C Hamano
Morten Welinder mwelin...@gmail.com writes: Is there a reason why picking among the choices in a sliding window must be contents neutral? Sorry, you might be getting at something interesting but I do not understand the question. I have no idea what you mean by contents neutral. Picking

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Javier Domingo
I must say it is _quite_ helpfull having the diffs well done (natural diffs as here named), just because when you want to review a patch on the fly, this sort of things are annoying. I just wanted to say my opinion. No idea on how to fix that, nor why does it happen. Javier Domingo 2012/12/12

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Junio C Hamano
Javier Domingo javier...@gmail.com writes: I must say it is _quite_ helpfull having the diffs well done (natural diffs as here named), just because when you want to review a patch on the fly, this sort of things are annoying. I do not think anybody is arguing that it would not help the human

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Michael Haggerty
On 12/12/2012 10:53 PM, Junio C Hamano wrote: Morten Welinder mwelin...@gmail.com writes: Is there a reason why picking among the choices in a sliding window must be contents neutral? Sorry, you might be getting at something interesting but I do not understand the question. I have no

Re: Fwd: possible Improving diff algoritm

2012-12-12 Thread Morten Welinder
Is there a reason why picking among the choices in a sliding window must be contents neutral? Sorry, you might be getting at something interesting but I do not understand the question. I have no idea what you mean by contents neutral. I was merely asking if an algorithm to pick between the

Re: possible Improving diff algoritm

2012-12-12 Thread Geert Bosch
On Dec 12, 2012, at 20:55, Morten Welinder mwelin...@gmail.com wrote: I was merely asking if an algorithm to pick between the 2+ choices was allowed to look at the contents of the lines. I.e., an algorithm would look at the C comment example and determine that the choice starting

Re: possible Improving diff algoritm

2012-12-12 Thread Junio C Hamano
Geert Bosch bo...@adacore.com writes: It would seem that just looking at the line length (stripped) of the last line, might be sufficient for cost function to minimize. Here the some would be 3 vs 0. In case of ties, use the last possibility with minimum cost. -- 8 -- #ifdef A some stuff