Description
Currently gitea only shows git diffs for text files, and can't for binary files.
git diff
has native support for custom drivers for converting binary files to text in order to display a diff.
Since gitea just runs the git diff
command and parses stdout
we can leverage this
gitea/services/gitdiff/gitdiff.go
Line 717 in 9542b73
By customising git config --global --edit
and adding:
[core]
quotePath = false
attributesfile = /root/gitea/custom/git/.gitattributes
[diff "pandoc"]
textconv=pandoc --to=markdown
prompt = false
Which is equivalent to running:
git config --global core.attributesfile /root/gitea/custom/git/.gitattributes
git config --global diff.pandoc.textconv "pandoc --to=markdown"
git config --global diff.pandoc.prompt false
And then creating the file /root/gitea/custom/git/.gitattributes
with contents:
*.docx diff=pandoc
The proposal
I propse that we allow users to implement this in an easier way, this could be done in a number of ways.
- Allow the user to customise their
git config --global
file - default location being/root/.gitconfig
- by using the includes field with value
$GITEA_CUSTOM/git/config
and allowing the user to configure that as they please - or by creating a new section in
app.ini
called something like [git.config] and allow the user to build a git config from the entries there - this may require translation between.ini
syntax and whatever syntaxgit config
uses
- by using the includes field with value
- Expand the external renderer section with new fields
CUSTOM_DIFF
andTEXTCONV_DIFF_COMMAND
and use that to autopopulate/root/.gitconfig
and a.gitattributes
file
Note 1.a
and 1.b
generailse to allow the user to configure all of the git config options, 2
is specific to the rendering of diffs