threads / discuss / 57793

Suggestion for the --word-diff

Subject: Suggestion for the --word-diff

## tl;dr

One message between Apr 25, 2022 and Apr 25, 2022.

replies: 0people: 1as markdown or json

Jason Mathison· Apr 25, 2022, 19:34 UTC · lore
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 

← back to recent threads