Community
Participate
Working Groups
Reproducer: $ mkdir difftest $ cd difftest $ git init $ echo "foo bar" > foo.txt $ git add . $ git commit -m "Space" [master (root-commit) c2c9c5a] Space 1 file changed, 1 insertion(+) create mode 100644 foo.txt $ echo -e "foo\tbar" > foo.txt $ git add . $ git commit -m "Tab" [master 51a56a0] Tab 1 file changed, 1 insertion(+), 1 deletion(-) $ git diff HEAD^1 HEAD diff --git a/foo.txt b/foo.txt index d675fa4..9a9b36b 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ -foo bar +foo bar $ git diff -b HEAD^1 HEAD $ jgit.sh diff HEAD^1 HEAD diff --git a/foo.txt b/foo.txt index d675fa4..9a9b36b 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ -foo bar +foo bar $ jgit.sh diff -b HEAD^1 HEAD diff --git a/foo.txt b/foo.txt index d675fa4..9a9b36b 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ -foo bar +foo bar $
The problem is that JGit compares the first whitespace characters of a sequence of whitespace characters. Continuing from above: $ echo -e "foo \tbar" > foo.txt $ git add . $ git commit -m "SpaceTab" [master ba0542f] SpaceTab 1 file changed, 1 insertion(+), 1 deletion(-) $ git diff -b HEAD~2 HEAD $ jgit.sh diff -b HEAD~2 HEAD diff --git a/foo.txt b/foo.txt index d675fa4..835a234 100644 --- a/foo.txt +++ b/foo.txt $ git diff -b HEAD~1 HEAD $ jgit.sh diff -b HEAD~1 HEAD diff --git a/foo.txt b/foo.txt index 9a9b36b..835a234 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ -foo bar +foo bar $
New Gerrit change created: https://git.eclipse.org/r/163573
Note that a difference between whitespace/no whitespace at the front _is_ significant. Continuing again: $ echo -e " foo\tbar" > foo.txt $ git add . $ git commit -m "Leading ws" $ git diff -b HEAD~2 HEAD diff --git a/foo.txt b/foo.txt index 9a9b36b..897da1b 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ -foo bar + foo bar $ jgit.sh diff -b HEAD~2 HEAD diff --git a/foo.txt b/foo.txt index 9a9b36b..897da1b 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ -foo bar + foo bar $ echo -e "\tfoo bar" > foo.txt $ git add . $ git commit -m "Leading tab" [master dfa7b42] Leading tab 1 file changed, 1 insertion(+), 1 deletion(-) $ git diff -b HEAD~1 HEAD $ jgit.sh diff -b HEAD~1 HEAD diff --git a/foo.txt b/foo.txt index 897da1b..2a883d6 100644 --- a/foo.txt +++ b/foo.txt @@ -1 +1 @@ - foo bar + foo bar $
Gerrit change https://git.eclipse.org/r/163573 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=6f17f9ed3fdadec1e6995f42ca34f570c0dee1b5