git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Suggestion for the --word-diff
       [not found] <SJ0PR10MB5645CAAA092FE04C6A76B31E99F49@SJ0PR10MB5645.namprd10.prod.outlook.com>
@ 2022-04-25 19:34 ` Jason Mathison
  0 siblings, 0 replies; only message in thread
From: Jason Mathison @ 2022-04-25 19:34 UTC (permalink / raw)
  To: git@vger.kernel.org

I ran into a situation where Git ends up giving a sort of strange diff in the --word-diff mode.

Starting with something like this

protected static String deleteMe = "I am going to be deleted";
protected static Var1 var1;
protected static Var2 Var2;
protected static Var3 Var3;

I then deleted the first line and removed static from everything ending up with

protected Var1 var1;
protected Var2 Var2;
protected Var3 Var3;

The strange thing about the diff is that it didn't completely delete the first line, but instead kept the protected on the first line and deleted it on the second line.

I created a Repo to reproduce what I was seeing
https://github.com/JasonMathison/BadDiff

git diff 76e4a079b5a985149ef09ebfd3df9f475d08fc93...4f8429ad13c4209ec375f67f60a3a797b6368088  --word-diff
diff --git a/code.java b/code.java
index d44a054..1118c6a 100644
--- a/code.java
+++ b/code.java
@@ -1,4 +1,3 @@
protected[-static String deleteMe = "I am going to be deleted";-]
[-protected static-] Var1 var1;
protected[-static-] Var2 Var2;
protected[-static-] Var3 Var3;

My suggestion is that the --word-diff prefer to remove an entire line in this situation.

--Jason 


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-25 19:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <SJ0PR10MB5645CAAA092FE04C6A76B31E99F49@SJ0PR10MB5645.namprd10.prod.outlook.com>
2022-04-25 19:34 ` Suggestion for the --word-diff Jason Mathison

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).