My project is structured like so:
/project
- file.json
- /submodule
- submodule-file.json
Where the /submodule
directory is a git submodule.
I have set up textconv to do some simple pre-processing of json files for diffing - my local .git/config
file contains
[diff "json"]
textconv = jq -S .
This works great for files in the main project - git diff file.json
works as expected. But it doesn't work for files in the submodule.
git diff submodule/submodule-file.json
produces no output at all.
cd submodule && git diff submodule-file.json
produces a diff without the textconv applied.
I would prefer not to make these settings global, and would be happy if I could have them only apply to the submodule.
Is this possible?
git version 2.26.1
I would prefer not to make these settings global, and would be happy if I could have them only apply to the submodule.
Yes, it's buried at the bottom of the description in the docs, but the top-priority source for attributes is the repo-local .git/info/attributes
, anything specified there overrides any committed attributes and your own defaults.
So find the repos where you want this diff applied, add \*.json diff=myjson
at the end of an info/attributes
file you probably have to make, and that'll override any diff specified elsewhere for that repo.
You can find the actual repository for an inited submodule with
git -C that/submodule rev-parse --absolute-git-dir
or to do them all for example
git submodule foreach --quiet --recursive git rev-parse --absolute-git-dir
and that's the directory whose info/attributes
file you want to update.