Sure. Should I modify the test repo whether create a file on-the-fly?

Per file encoding can be specified in .gitattributes file.
https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html#_viewing_files_in_gui_tools

I imagine that there could be IFilesEncodingResolver as a property of Repository.