Sometimes git diff will return something like this:
diff --git a/file.x b/file.x
index aaaaaaa..bbbbbbb 000000
--- a/file.x
+++ b/file.x
for (int i = 0; i < 5; i++)
- {
- // code
- }
-
- // other code
-
- for (int i = 0; i < 5; i++)
{
// more code
}
Is there any way to force git to show this diff as the following, which more accurately represents the real change?
diff --git a/file.x b/file.x
index aaaaaaa..bbbbbbb 000000
--- a/file.x
+++ b/file.x
- for (int i = 0; i < 5; i++)
- {
- // code
- }
-
- // other code
-
for (int i = 0; i < 5; i++)
{
// more code
}
The difference above is the for (...)
line that the diff thinks has been removed is in two different places. I appreciate this is entirely cosmetic, I'd just like to know.
Edit: I have tried
git diff -W a b
as @Michael Durrant suggested, but this does not change the output in this case.