diff --break-rewrites for just a part of a file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

diff --break-rewrites for just a part of a file

Sascha Silbe-2
Hello,

the other day I was reviewing a patch that replaced a large chunk in a
Makefile with completely different logic. No matter what diff algorithm
and options I threw at it, the diff would always synchronise at the
empty lines between individual targets and thus show the rewrite of a
larger section as complete replacements of many smaller, but directly
adjacent sections (only separated by a blank line).

--break-rewrites would be nicely suited for this case, but once I dialed
down the parameters enough for the option to apply at all, it showed the
entire file as being replaced rather than just the section in between
that actually changed. Is there a way to have --break-rewrites leave out
the unchanged lines at beginning and end of the file?

A combination of --break-rewrites and --inter-hunk-context that merges
changes with less than the given number of unchanged lines between them
into a single delete/insert change would be even better. But just
ignoring the unchanged header and footer of a file for --break-rewrites
would already go a long way.

Sascha

attachment0 (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: diff --break-rewrites for just a part of a file

Junio C Hamano
Sascha Silbe <[hidden email]> writes:

> A combination of --break-rewrites and --inter-hunk-context that merges
> changes with less than the given number of unchanged lines between them
> into a single delete/insert change would be even better. But just
> ignoring the unchanged header and footer of a file for --break-rewrites
> would already go a long way.

That's interesting.  Break-rewrites as originally designed and
implemented is only about "When the entire file been rewritten
completely, it is easier to read when the diff did not pay any
attention to those accidentally common lines".

We recently had a discussion on tweaking the logic used to merge and
minimize hunks; the topic was about where to start the hunk boundary
for maximum readability when the beginning and end of a hunk can be
shifted around, but this smells like a similar issue.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html