Skip to content

Instantly share code, notes, and snippets.

@infotroph
Last active December 17, 2015 02:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infotroph/5535527 to your computer and use it in GitHub Desktop.
Save infotroph/5535527 to your computer and use it in GitHub Desktop.
A quick and dirty approach to make git-diff on MS Office documents use the decompressed XML instead of treating them as binary. Known bugs: Complains on empty components (notably including the always-present [Content_Types].xml), and actually shows all changes to the XML (so good luck finding meaningful changes to an Excel file under all the dis…
# /usr/local/bin/xmlzip.sh:
#!/bin/bash
for i in `unzip -Z -1 "$1"`; do
echo "$i"
unzip -a -p "$1" "$i" | xmllint --format -
done
# ~/.gitconfig:
[diff "xmlzip"]
textconv = /usr/local/bin/xmlzip.sh
# .gitattributes:
*.xlsx diff=xmlzip
*.docx diff=xmlzip
*.pptx diff=xmlzip
@aredridel
Copy link

Awesome! Can I suggest making it an actual project repo?

@infotroph
Copy link
Author

Good idea. I finally did that: Check gitMSOfficeDiff for any updates to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment