Open HarvsG opened 4 years ago
Currently git config
is run here in the checkAndSetConfig()
command
https://github.com/go-gitea/gitea/blob/ae3cfa844945f446b511dbcae358b3f5b930b3ce/modules/git/git.go#L159-L161
here (not sure this one is relevant) https://github.com/go-gitea/gitea/blob/c52d48aae46af879fdfcfd94d03b7072878b5441/services/pull/merge.go#L159-L168
and here (also probably not relevant) https://github.com/go-gitea/gitea/blob/801843b0115e29ba2304fa6a5bea1ae169a58e02/integrations/gitea-repositories-meta/user2/repo1.wiki.git/hooks/update.sample#L45-L50
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 parsesstdout
we can leverage this https://github.com/go-gitea/gitea/blob/9542b7317da36f366545803f77e250036b168318/services/gitdiff/gitdiff.go#L717By customising
git config --global --edit
and adding:Which is equivalent to running:
And then creating the file
/root/gitea/custom/git/.gitattributes
with contents:We get a much better outpjut:
The proposal
I propse that we allow users to implement this in an easier way, this could be done in a number of ways.
git config --global
file - default location being/root/.gitconfig
$GITEA_CUSTOM/git/config
and allowing the user to configure that as they pleaseapp.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
usesCUSTOM_DIFF
andTEXTCONV_DIFF_COMMAND
and use that to autopopulate/root/.gitconfig
and a.gitattributes
fileNote
1.a
and1.b
generailse to allow the user to configure all of the git config options,2
is specific to the rendering of diffs