Person/Zack Steinkamp/blog/posts/2022-02-15-git-diff-amxd-max
Properties
- tags
- c74/M4L
- created-by
- Person/Zack Steinkamp
Making 'git diff' Work For .amxd
- My Notes
- See also the source material at steinkamp.us/pages/posts/2022-02-15-git-diff-amxd-max.md at main · zsteinkamp/steinkamp.us · GitHub
- #Quotes
- Here's a quick tip if you're using git for revision control in developing Max/MSP or Max For Live devices.
- Perhaps you have been here?
- bash
$ git diff diff --git a/cool.amxd b/cool.amxd index c7a9b88..afdafb1 100644 Binary files a/cool.amxd and b/cool.amxd differ .amxdfiles are basically JSON, but with a non-JSON file header. This binary part at the beginning makes git fall back to binary file mode when trying to show diffs. Usualy that's not very helpful.
There's just a bit of configuration to make thegit diffoutput more helpful. Here's what to do:- 1. Create a global
.gitattributesfile in your home directory. This will will map the.amxdfile extension to a named file type that we will use later. Run this command to create the file with the correct contents: - bash
echo '*.amxd binary diff=amxd' > ~/.gitattributes - 2. Now tell git where to find the new global
.gitattributesfile. Run this command: - bash
git config --global core.attributesfile ~/.gitattributes - 3. The final step is to tell git how to convert the 'binary' file to text when displaying a diff. Add this content to your
~/.gitconfigfile: - config
[diff "amxd"] textconv = awk '(NR>1)' binary = true - 3. The final step is to tell git how to convert the 'binary' file to text when displaying a diff. Add this content to your
~/.gitconfigfile: - config
[diff "amxd"] textconv = awk '(NR>1)' binary = true - In this case, we're using
awkto suppress printing the first line. That's good enough for my uses, but if you are anawkwizard and you want to use a tool likejqto work with the JSON data, perhaps you can suppress everything to the initial{on that first line.
- My Notes