Community
Participate
Working Groups
Created attachment 281797 [details] Repository demonstrating the bug. Create two commits which produce following diff in native git. (In attached repo it is enough to use: git show --ignore-all-space ) diff --git a/ws.java b/ws.java index 4217297..30b4aa9 100644 --- a/ws.java +++ b/ws.java @@ -1,11 +1,11 @@ +if ( cond ) { my first code block +} -if (cond) { my second code block -} Now try to show the diff using jgit (jgit show --ignore-all-space) it will give: diff --git a/ws.java b/ws.java index 4217297..30b4aa9 100644 --- a/ws.java +++ b/ws.java @@ -1,11 +1,11 @@ +if ( cond ) { my first code block +} -if (cond) { my second code block -} Notice that the indentation is wrong.
Why would JGit be wrong? The lines are considered equivalent since the differ is instructed to ignore whitespace. That said, git/xdiff/xemit.c emits context lines (same in both files) from file B, whereas org.eclipse.jgit.diff.DiffFormatter.java emits them from file A. Normally that doesn't matter since the lines will be the same in both files, but when whitespace is ignored, there may be such differences. JGit's way has the advantage that the resulting diff could be applied as a patch even without "whitespace ignore" flags.