git diff for binary Apple property list files
In the same vein as diffing UTF-16 .strings files in git:
It’s easy to set up git to show diffs for binary .plist files.
- Add a
textconvkey for this conversion to your~/.gitconfig:
git config --global diff.plist.textconv "plutil -convert xml1 -o -"
In your global .gitconfig, it’ll look like this:
[diff "plist"] textconv = plutil -convert xml1 -o -
- Add a mapping from filename to diff command to your project’s
.gitattributesfile:
echo "*.plist diff=plist" >> .gitattributes
- (Bonus points) Set up a global
.gitattributesfile via this Q&A on Stack Overflow to always do this:
git config --global core.attributesfile $HOME/.gitattributes echo "*.plist diff=plist" >> ~/.gitattributes
What this looks like in practice:
% ± file Info.plist
Info.plist: Apple binary property list
% ± git log -p Info.plist
commit 5ba260528509cca6ac9e6a9080543dbfbc7a7561
Author: Christopher Bowns
Date: Thu Nov 12 21:42:06 2015 -0800
A new key-value.
diff --git a/Info.plist b/Info.plist
index 313794c..a619e52 100644
--- a/Info.plist
+++ b/Info.plist
@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">>>
<plist version="1.0">
<dict>
+ <key>ANewKey</key>
+ <string>IAmAValue</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>