git diff says "Binary files differ" for a large file
The file is plain text. Git still refuses to show a diff once it passes 512 MiB.
rift git-diff ships in 0.3.0.
Git decides a file is binary when it is larger than 512 MiB. It prints one line and no diff. This is a 640 MiB pair of generated SQL dumps:
$ git diff --no-index a.sql b.sql diff --git a/a.sql b/b.sql index 86d4681..61a1efd 100644 Binary files a/a.sql and b/b.sql differ
The fix
Tell git to run Rift for the large files:
echo '*.sql diff=rift' >> .gitattributes
git config diff.rift.command 'rift git-diff --mem 1G'
The same command on the same pair, with Rift as the external diff:
$ git -c diff.external='rift git-diff' diff --no-index a.sql b.sql > out.diff $ head -n 12 out.diff | cut -c1-100 diff --git a/a.sql b/b.sql index 86d4681..61a1efd 100644 --- a/a.sql +++ b/b.sql @@ -380,7 +380,6 @@ INSERT INTO public.orders (id, customer_id, status, amount, note) VALUES (380, 514366, 'shipped', 5 381 178722 cancelled 2930.54 wmojdqnzik INSERT INTO public.orders (id, customer_id, status, amount, note) VALUES (382, 679322, 'cancelled', -383 668107 shipped 5325.74 zu INSERT INTO public.orders (id, customer_id, status, amount, note) VALUES (384, 442363, 'new', 6149. 385 359182 cancelled 475.15 ztbyhdlmxk INSERT INTO public.orders (id, customer_id, status, amount, note) VALUES (386, 967299, 'shipped', 4
Git's own headers stay, and the hunks come from Rift. Other files keep git's diff, because only *.sql is named in .gitattributes.
Before you rely on it
- Git writes each blob that is not in the work tree to a temporary file before it runs the command. For a file not stored with LFS that is a full copy: 10 GB of disk for a 10 GB file.
- For an LFS file Rift reads the object from
.git/lfs/objectsin place, with no copy. rift git-diffexits 0 whether or not the files differ, because git treats any other status as a failure.
The full setup, including git difftool for the terminal view, is in the git guide.