Having WXME files in git repositories can be frustrating. They are not readable in other editors. Git can't display them in git diff and git show. But don't give up yet! Git supports custom filters that allows one to customize conversion from binary files to text, which can generate useful outputs when working with binary files. Some git implementation already includesuch configurations for PDFs. Let's add one for WXME files.
-
Create this
racket-wxme-astextscript and make it available in your$PATH. When the specified file is identified as a binary file, it useswxme-port->text-portto extract readable texts from WXME files. Remember tochmod u+x racket-wxme-astext.#!/bin/bash if [ $# -ne 1 ]; then echo Usage: racket-wxme-astext FILE >&2 exit 1 fi if ! file --mime "$1" | grep octet-stream > /dev/null; then cat "$1" else cat "$1" | racket -n -l racket/base -l wxme -l racket/port \ -e '(copy-port (wxme-port->text-port (current-input-port)) (current-output-port))' fi -
Identify Racket files in GIT attributes. Add this line to either
<PROJECT_ROOT>/.gitattributes,<PROJECT_ROOT>/.git/info/attributesor$XDG_CONFIG_HOME/git/attributes:*.rkt diff=wxme -
Hook
racket-wxme-astextforwxmetype in git:git config --local diff.wxme.textconv racket-wxme-astextReplace
--localby--globalif you want to enableracket-wxme-astextfor all repositories (in which case you need to use the third git attribute file in the previous step).Instead of using
git config, you can also stash the following content in either<PROJECT_ROOT>/.git/config,~/.gitconfigor$XDG_CONFIG_HOME/git/config:[diff "wxme"] textconv = racket-wxme-astext
