Skip to content

Force commit messages output to UTF-8 - #331087

Merged
Dmitriy Vasyura (dmitrivMS) merged 13 commits into
microsoft:mainfrom
yutotnh:fix-non-utf8-commit-message
Sep 8, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 13 commits into
microsoft:mainfrom
yutotnh:fix-non-utf8-commit-message

Conversation

@yutotnh

Copy link
Copy Markdown
Contributor

Fixes #331086

Summary

I modified the code to enforce the i18n.logOutputEncoding=UTF-8 setting when calling Git.

Test

The test I added checks whether commit messages written in an encoding other than UTF-8 (EUC-JP) are retrieved as UTF-8.
Without my fix, they would be retrieved as EUC-JP, causing the test to fail.

Image

image

Additional Information

Even after applying this setting, my local test results showed that the execution time remained unchanged.

I conducted the following experiment in the vscode repository.

If no settings are specified

$ time for i in $(seq 1 10) ;do git --no-pager log >& /tmp/output.txt ; done

real    0m12.062s
user    0m11.392s
sys     0m0.647s

If a setting is specified

$ time for i in $(seq 1 10) ;do git --no-pager -c i18n.logOutputEncoding=UTF-8 log >& /tmp/output.txt ; done

real    0m11.824s
user    0m11.034s
sys     0m0.768s

Copilot AI balanced review requested due to automatic review settings August 16, 2026 16:13
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • extensions/git/src/git.ts
  • extensions/git/src/test/smoke.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves handling of non-UTF-8 commit message encodings by forcing Git log output to UTF-8 and adds a smoke test to validate that behavior.

Changes:

  • Added a smoke test that commits an EUC-JP encoded message and asserts it’s read back as UTF-8.
  • Updated Git process spawning to apply i18n.logOutputEncoding=UTF-8 via -c for spawned Git commands.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
extensions/git/src/test/smoke.test.ts Adds coverage for reading non-UTF-8 commit messages via repository log.
extensions/git/src/git.ts Forces Git log output encoding to UTF-8 by injecting -c i18n.logOutputEncoding=UTF-8.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread extensions/git/src/git.ts Resolved
Comment thread extensions/git/src/test/smoke.test.ts Resolved
Comment thread extensions/git/src/test/smoke.test.ts Resolved
Comment thread extensions/git/src/test/smoke.test.ts Resolved
@dmitrivMS

Copy link
Copy Markdown
Collaborator

yutotnh (@yutotnh) Could you please address Copilot's comments?

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@yutotnh

Copy link
Copy Markdown
Contributor Author

Dmitriy Vasyura (@dmitrivMS) Thanks for the comment.
I’ll work on this over the next few days.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread extensions/git/src/test/smoke.test.ts Resolved
Comment thread extensions/git/src/git.ts Resolved
Comment thread extensions/git/src/git.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 4127665 into microsoft:main Sep 8, 2026
29 of 30 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.138.0 milestone Sep 8, 2026
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 27, 2026
* Force commit messages output to UTF-8

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* Capture i18n.commitEncoding before tests and restore it afterward

* Restrict UTF-8 log output to commit message display commands

* Remove the `forceUtf8LogOutputEncoding` option and change it to pass `-c` directly instead.

* Set i18n.logOutputEncoding and restore it afterward

* Cover blame2 and other internal methods in the i18n.logOutputEncoding test

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Dmitriy Vasyura <[email protected]>
(cherry picked from commit 4127665)
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commit messages garbled depending on Git settings

4 participants