Simplify diffing & merging of message & parser generated files through .gitattributes
There was some interest in this on mattermost so it's worth creating an issue.
Generated messages & generated parser files are meaningless to inspect. Their source files are easier to read. So there are two things we can do with git attributes.:
- Not clutter entire screens with differences of generated files when diff-ing branches or commits or so on. This can be done via the
diff=nodiff
attribute. - Temporarily trick git into solving these spurious conflicts on generated files since a regeneration has to happen anyway. This can be done via
merge=ours
ormerge=theirs
attributes. Almost certainly both are wrong, but there's no magicalmerge=$(make messages && make parsers)
so they would have to do. Advantage ofmerge=ours
: zero diff, but you will probably have other conflicts and that means other modified files so it let's you focus on them. Advantage ofmerge=theirs
: some diff which will tell you nothing more than what files need regenerating.
Git attributes are assigned per file or directory. Since we have generated message & parser files in open directories with other source code files, our attributes would work directly associated with the generated files.