isaacs / github

Just a place to track issues and feature requests that I have for github
2.21k stars 129 forks source link

web-based diff shows a different diff than cmd-line git output... #717

Open jens-maus opened 8 years ago

jens-maus commented 8 years ago

I came across a potential bug of the web-based diff tool in github where for one specific diff the web-based diff tool somehow shows something completely different (in fact a NOP) than using the cmd-line "git diff" which actually should be the gold standard.

See here: https://github.com/Thinstation/thinstation/commit/b6b8b13c4e22955d1cc022b53a07ed4d590d732e

Using cmd-line "git diff" for this commit show the following diff, however:

# git diff b6b8b13c4e22955d1cc022b53a07ed4d590d732e ts/build/build
diff --git a/ts/build/build b/ts/build/build
index d3f1c4d..e7efd65 100755
--- a/ts/build/build
+++ b/ts/build/build
@@ -995,7 +995,7 @@ do
                done
        fi
        if [ `make_caps X$args` == "XFORCE" ]; then
-               echo $name >> ./tmp-tree/etc/modules
+               echo $name `echo $args | cut -f1 -d#` >> ./tmp-tree/etc/modules
        fi
        ;;
     module_pkg)
@@ -1523,7 +1523,7 @@ for filename in `ls -1 $PKGDIR/` ; do
                rm -Rf build
        fi
        echo "Building $filename.pkg"
-       tar -cJf ../$filename.pkg *
+       tar -cz * > ../$filename.pkg
        cd ../../..
        rm -Rf $PKGDIR/$filename
        if [ -n "$PKGFILES" ] ; then
cirosantilli commented 8 years ago

Argh, that repo is huge, I don't have the patience to clone. Can you produce a minimal example repo?

Note that git diff offers multiple algorithms, and the default may have changed with git version, so it is not so simple to use it as a gold standard.

But yes, in this case, it does not seems that the problem comes from an algorithm difference...

cirosantilli commented 8 years ago

I've downloaded the 3 versions of ts/build/buid, and I reproduce your diff locally.

The GitHub diff is too lines off (actual changes happen 2 lines above the lines shown on github diff)

Web archive: https://web.archive.org/save/https://github.com/Thinstation/thinstation/commit/b6b8b13c4e22955d1cc022b53a07ed4d590d732e

cirosantilli commented 8 years ago

Reproduced and minimized to a single 150 loc file, 2 commit, no merges repo: https://github.com/Thinstation/thinstation/commit/b6b8b13c4e22955d1cc022b53a07ed4d590d732e

There are no non-printable chars in that file:

tr -d '[[:print:]]\n' <1 | wc

If I try to bisect further it stops reproducing...

https://web.archive.org/web/20160715203909/https://github.com/cirosantilli/test-wrong-diff/commit/0c5f6da38edcc4e79fd8080fb9c9477f7d613478