git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jason Mathison <Jason.Mathison@genesys.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Suggestion for the --word-diff
Date: Mon, 25 Apr 2022 19:34:15 +0000	[thread overview]
Message-ID: <SJ0PR10MB564512089A259429773C2C7899F89@SJ0PR10MB5645.namprd10.prod.outlook.com> (raw)
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 


           reply	other threads:[~2022-04-25 19:36 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <SJ0PR10MB5645CAAA092FE04C6A76B31E99F49@SJ0PR10MB5645.namprd10.prod.outlook.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR10MB564512089A259429773C2C7899F89@SJ0PR10MB5645.namprd10.prod.outlook.com \
    --to=jason.mathison@genesys.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).