I started to pay a little more attention to the diff files that I create (using git), and I am unhappy with the clarity of the diff created by this situation.
I'll start with:
sub main { my $self = shift; return $self; }
Then I add a second function and a call to it in the first to get:
sub main { my $self = shift; $self -> process ( 'hello world!' ); return $self; } sub process { my $self = shift; print @_, "\n"; return $self; }
The output of the diff that I get for this is:
@@ -1,5 +1,15 @@ sub main { my $self = shift; + $self -> process ( 'hello world!' ); + + return $self; +} + +sub process { + my $self = shift; + + print @_, "\n"; + return $self; }
It seems very untidy and incomprehensible to the reader to me. A piece of padding makes it look like I'm adding a lot of lines to the "main" function, when I actually have the most lines added after it. For example, I would expect diff to look like this:
@@ -1,5 +1,15 @@ sub main { my $self = shift; + $self -> process ( 'hello world!' ); + return $self; } + +sub process { + my $self = shift; + + print @_, "\n"; + + return $self; +}
I understand why diff creates this output (the easiest way to go from "a → b"), but I would like it to be clarified. Is it possible? Or am I looking at manually editing the differences or even splitting the addition of a new function and calling it into 2 separate patches / commits? [1]
I tried using the algorithms --no-minimal, -patience and -histogram, but the diff result is identical. Manually editing diff with "git add -p" does not matter; it is still the first, "fuzzy" difference.
[1] As a side question, is this separation what I should really do anyway?