git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Can I convince the diff algorithm to behave better?
@ 2021-03-03  2:03 Tom Ritter
  2021-03-03 12:41 ` Thomas Braun
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Ritter @ 2021-03-03  2:03 UTC (permalink / raw)
  To: git

(For a specific, nuanced, and personal definition of better...)

I have a frequent behavior that arises when I am copy/pasting chunks
of code, typically in tests.  Here is an example:

My Original code:

def function():
   line 1
   line 2
   line 3
   line 4
   line 5
   line 6

--------------------------------
I add, after it:

def function2():
   line 1
   line 2
   line 3
   line 4
   line 5
   line 6

--------------------------------
My diff is:

+   line 3
+   line 4
+   line 5
+   line 6
+
+def function2():
+   line 1
+   line 2

--------------------------------
I'd like my diff to be

+
+def function2():
+   line 1
+   line 2
+   line 3
+   line 4
+   line 5
+   line 6


Obviously there's nothing incorrect about the former diff, I just wish
it was the latter rather than the former.

I know that git includes four diff algorithms; in my testing patience
or histogram exacerbated the problem; and none of them improved upon
it.  If anyone has suggestions I'd be curious to know if there's
anything that could be done...

Thanks,
-tom

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

end of thread, other threads:[~2021-03-04  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03  2:03 Can I convince the diff algorithm to behave better? Tom Ritter
2021-03-03 12:41 ` Thomas Braun
2021-03-03 23:45 ` Jonathan Tan
2021-03-04  9:52 ` Christian Couder

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).