All of lore.kernel.org
 help / color / mirror / Atom feed
* Searching explanation of different diff algorithms
@ 2013-09-25  7:24 Thomas Koch
  2013-09-25  8:55 ` Ondřej Bílka
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koch @ 2013-09-25  7:24 UTC (permalink / raw)
  To: git

Is there any explanation available of the different merrits and drawbacks of 
the diff algorithms that Git supports?

I'm not satisfied with the default diff but have enough processing power for a 
slower algorithm that might produce diffs that better show the intention of the 
edit.

Thank you, Thomas Koch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Searching explanation of different diff algorithms
  2013-09-25  7:24 Searching explanation of different diff algorithms Thomas Koch
@ 2013-09-25  8:55 ` Ondřej Bílka
  2013-09-25 15:30   ` Peter Oberndorfer
  0 siblings, 1 reply; 3+ messages in thread
From: Ondřej Bílka @ 2013-09-25  8:55 UTC (permalink / raw)
  To: Thomas Koch; +Cc: git

On Wed, Sep 25, 2013 at 09:24:15AM +0200, Thomas Koch wrote:
> Is there any explanation available of the different merrits and drawbacks of 
> the diff algorithms that Git supports?
> 
> I'm not satisfied with the default diff but have enough processing power for a 
> slower algorithm that might produce diffs that better show the intention of the 
> edit.
> 
It is not just question of algorithm, even definition how should most
readable diff look like is problematic, for example when large block is
rewritten and one line is unchanged then you get diff like

if (x){
- foo
+ bar
} else {
- foo
+ bar
}

but it is better to create following diff as it does not break flow of code.

if (x) {
- foo
-} else {
- foo
+ bar
+} else {
+ bar
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Searching explanation of different diff algorithms
  2013-09-25  8:55 ` Ondřej Bílka
@ 2013-09-25 15:30   ` Peter Oberndorfer
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Oberndorfer @ 2013-09-25 15:30 UTC (permalink / raw)
  To: Ondřej Bílka; +Cc: Thomas Koch, git

On 2013-09-25 10:55, Ondřej Bílka wrote:
> On Wed, Sep 25, 2013 at 09:24:15AM +0200, Thomas Koch wrote:
>> Is there any explanation available of the different merrits and drawbacks of 
>> the diff algorithms that Git supports?
>>
>> I'm not satisfied with the default diff but have enough processing power for a 
>> slower algorithm that might produce diffs that better show the intention of the 
>> edit.
>>
> It is not just question of algorithm, even definition how should most
> readable diff look like is problematic, for example when large block is
> rewritten and one line is unchanged then you get diff like
> 
> if (x){
> - foo
> + bar
> } else {
> - foo
> + bar
> }
> 
> but it is better to create following diff as it does not break flow of code.
> 
> if (x) {
> - foo
> -} else {
> - foo
> + bar
> +} else {
> + bar
> }

I already asked the list for such a feature in the past[1].
I might be able to provide a rough/unfinished hack
that does exactly this in a few days after cleaning it up a bit.

It works like this:
If 2 hunks are separated by less than a certain count of lines and
those lines are identified as containing no "interesting information"
like {, }, /*, */, <whitespace> then the 2 hunks are fused together.

The hack is mainly lacking the following things:
* A way to identify boring lines.
(a like a list of boring keywords?, per filetype?)
* Configuration/commandline options to turn it on/off
* Tests
* Cleanup the code

Greetings Peter

[1] http://article.gmane.org/gmane.comp.version-control.git/207239/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-25 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-25  7:24 Searching explanation of different diff algorithms Thomas Koch
2013-09-25  8:55 ` Ondřej Bílka
2013-09-25 15:30   ` Peter Oberndorfer

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.