git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Suggestion for the --word-diff

From
JMJason Mathison <jason.mathison@genesys.com>
Date
Apr 25, 2022, 19:34 UTC
Message-ID
<SJ0PR10MB564512089A259429773C2C7899F89@SJ0PR10MB5645.namprd10.prod.outlook.com>
In-Reply-To
<SJ0PR10MB5645CAAA092FE04C6A76B31E99F49@SJ0PR10MB5645.namprd10.prod.outlook.com>
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 
Message 1 of 1 in “Suggestion for the --word-diff”
  1. Jason MathisonApr 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.