Manually assign iconv for diffing
Another answer suggested trying *.reg working-tree-encoding=UTF-16LE-BOM eol=CRLF
This did not work for me. I'm on Windows 10 and TortoiseGit didn't realize that the file was actually unchanged.
I have a bat file that dumps Tomcat registry to disk and after running that the TortoiseGit icon would always be red. But I would immediately turn green if I ran git status
on the command line. -- Not sure what's going on there.
So I wound up with something else. I don't touch the internal encoding, I just manually define a diffing program to use for UTF-16 files and then I manually assign .reg files to use that. This works on git-bash-for-windows for me. And I don't have the problem in Windows Explorer with the red "this-has-changed" TortoiseGit icon overlay.
There are two steps:
Define diffing program:
$ git config --global diff.utf16file.textconv "iconv --from-code=UTF-16 --to-code=UTF-8"
Assign .reg files to use that:
$ cat .gitattributes
*.reg diff=utf16file
More details below.
I have a batch file which does this:
del ApacheSoftwareFoundation.Wow6432Node.reg
reg export "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation" ApacheSoftwareFoundation.Wow6432Node.reg /y
Now I ran this export batch file, then I changed the "timeout" value from 60 seconds to 66 seconds via Tomcat9 GUI and then I ran the export batch file again.
Before: you get no textual diff. You just get "Binary files ... differ"
$ git config --unset --global diff.utf16file.textconv
✘
$ git config --global diff.utf16file.textconv
✘
$ git check-attr --all ApacheSoftwareFoundation.Wow6432Node.reg
✔
$ git diff ApacheSoftwareFoundation.Wow6432Node.reg
diff --git a/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg b/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg
index 8c860ae..ad840d5 100644
Binary files a/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg and b/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg differ
✔
$ git diff ApacheSoftwareFoundation.Wow6432Node.reg
diff --git a/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg b/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg
index 8c860ae..ad840d5 100644
Binary files a/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg and b/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg differ
✔
After: you get an actual diff.
$ echo '*.reg diff=utf16file' >> .gitattributes
✔
$ git config --global diff.utf16file.textconv "iconv --from-code=UTF-16 --to-code=UTF-8"
✔
$ git config --global diff.utf16file.textconv
iconv --from-code=UTF-16 --to-code=UTF-8
✔
$ git check-attr --all ApacheSoftwareFoundation.Wow6432Node.reg
ApacheSoftwareFoundation.Wow6432Node.reg: diff: utf16file
✔
$ git diff ApacheSoftwareFoundation.Wow6432Node.reg
diff --git a/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg b/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg
index 8c860ae..ad840d5 100644
--- a/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg
+++ b/Tomcat9/bin/ApacheSoftwareFoundation.Wow6432Node.reg
@@ -202,5 +202,5 @@ Windows Registry Editor Version 5.00
"Class"="org.apache.catalina.startup.Bootstrap"
"Params"=hex(7):73,00,74,00,6f,00,70,00,00,00,00,00,00,00
"Mode"="jvm"
-"Timeout"=dword:0000003c
+"Timeout"=dword:00000042
✔
git difftool file
. – Latchet