Skip to content

Log() and Commit() return garbled non-ASCII text, and Commit() writes mojibake, on hosts that set i18n.logOutputEncoding / i18n.commitEncoding #246

Open

Description

@matt-edmondson

What's wrong

The library decodes git's standard output as UTF-8, but two verbs never pin the encoding git uses. That leaves them exposed to host configuration, which is the same class of problem the existing "pin host config" design points already guard against, for example --no-show-signature and --no-follow in GitLogBuilder.

  1. Reading: GitLogBuilder.AppendVerbArguments (GitIntegration/Builders/GitLogBuilder.cs, about lines 158-173) emits log --no-show-signature --no-follow -z --format=… without --encoding=UTF-8. When a host sets i18n.logOutputEncoding, or only i18n.commitEncoding (which logOutputEncoding defaults to), git re-encodes author names and messages into that charset. Commit() reuses this vector for its log -1 read-back (GitCommitBuilder.cs about lines 257-261), so it is affected too.
  2. Writing: GitCommitBuilder (GitIntegration/Builders/GitCommitBuilder.cs, about lines 115-136) runs commit without -c i18n.commitEncoding=UTF-8. git writes the argv bytes, which are UTF-8 from .NET, under whatever encoding header the host config says.

Failure scenario (reproduced with git 2.43)

  • Create a UTF-8 commit with author José and message café.
  • git -c i18n.logOutputEncoding=ISO-8859-1 log -1 --format=%an|%B emits the single byte 0xE9 for each é.
  • Decoded as UTF-8, that byte becomes U+FFFD, so Log() reports Jos� / caf�. Commit()'s returned GitCommit is garbled the same way.
  • With --encoding=UTF-8 git emits the correct bytes C3 A9.
  • git -c i18n.commitEncoding=ISO-8859-1 commit -m 'naïve' stores UTF-8 bytes under an encoding ISO-8859-1 header.
  • Every standard reader, including GitHub, then shows naïve. The library has permanently written mojibake into history.

Suggested fix

  • Add --encoding=UTF-8 to GitLogBuilder's argument vector. This also fixes Commit()'s read-back.
  • Add -c i18n.commitEncoding=UTF-8 before the commit verb in GitCommitBuilder, the same way GitPatchBuilder places its -c pin ahead of the verb.

Acceptance criteria

  • Argument-vector tests assert both pins.
  • An integration test with -c i18n.logOutputEncoding=ISO-8859-1 (or the repo config set to that value) and a non-ASCII author and subject round-trips through Log() and Commit() unchanged.
  • An integration test with i18n.commitEncoding=ISO-8859-1 confirms the stored commit has no non-UTF-8 encoding header, or that it reads back correctly with plain git log.

Activity

  1. matt-edmondson commented on Oct 18, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions