That code in GitDocument#populate is in priciple way better. I missed to take into account encoding on file level. 

However, it still had a bug (if (charset != null)) and did not work for file encoding different.

I fixed that bug and refactored it for reuse.