Skip to content

Git: Stash messages appear garbled when i18n.logOutputEncoding is set #339256

Closed

Description

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.140.0 / main
  • OS Version: Windows / macOS / Linux

In extensions/git/src/git.ts, Repository.getStashes() runs git stash list without forcing the output encoding to UTF-8. If a repository or global gitconfig sets i18n.logOutputEncoding (or i18n.commitEncoding), non-ASCII stash messages appear as corrupted characters (Mojibake) in the Source Control Stashes view and related QuickPicks.

This is a follow-up to #331086 / PR #331087, which added -c i18n.logOutputEncoding=UTF-8 to log, logFile, blame2, getCommit, and showChanges, but missed getStashes.

Steps to Reproduce:

  1. Initialize a repository with non-UTF-8 encoding configured:
    git init test-repo
    cd test-repo
    git commit --allow-empty -m "initial"
    echo "sample" > file.txt
    git add file.txt
    git config i18n.commitEncoding EUC-JP
    git config i18n.logOutputEncoding EUC-JP
  2. Create a stash with a non-ASCII message (e.g., EUC-JP text):
    git stash push -m "$(printf '\xa5\xc6\xa5\xb9\xa5\xc8 stash')"
  3. Open the folder in VS Code with extensions disabled (code --disable-extensions .).
  4. Inspect the stash in the Source Control panel or via Git: Pop Stash....

Expected Behavior:
The stash message is decoded and displayed as On master: テスト stash.

Actual Behavior:
The stash message displays as On master: ƥ stash.

Direct CLI comparison:

# Current git.ts behavior (garbled output)
$ git stash list
stash@{0}: On master: ƥ stash

# Expected git.ts behavior (with -c i18n.logOutputEncoding=UTF-8)
$ git -c i18n.logOutputEncoding=UTF-8 stash list
stash@{0}: On master: テスト stash

Cause:
In extensions/git/src/git.ts:3022:

async getStashes(): Promise<Stash[]> {
	const result = await this.exec(['stash', 'list', `--format=${STASH_FORMAT}`, '-z']);
	return parseGitStashes(result.stdout.trim());
}

Because this.exec() decodes stdout using bufferResult.stdout.toString('utf8') (line 657), git stash list needs -c i18n.logOutputEncoding=UTF-8 prepended to ensure Git converts the commit message to UTF-8 before writing to stdout:

const result = await this.exec(['-c', 'i18n.logOutputEncoding=UTF-8', 'stash', 'list', `--format=${STASH_FORMAT}`, '-z']);

Activity

  1. lszomoru commented on Nov 23, 2026

    @lszomoru
    Member

    I can reproduce this in VS Code Insiders 1.148.0 on Linux (git 2.43.0):

    1. In a repository, set git config i18n.logOutputEncoding EUC-JP.
    2. Stage a change and run git stash push -m "テスト stash".
    3. Open the folder and run Git: Apply Stash....

    The picker shows #0: �ƥ��� stash instead of #0: テスト stash. The Stashes view shows the same text. getStashes() reads git stash list as UTF-8 but, unlike log, blame and show (#331087), it doesn't ask git for UTF-8 output.

    A note on the exact steps above, where the message bytes themselves are EUC-JP (i18n.commitEncoding EUC-JP plus a raw EUC-JP message): the stash list shows the stash's reflog subject (%gs), and git doesn't re-encode reflog subjects. Even git -c i18n.logOutputEncoding=UTF-8 stash list --format=%gs prints those bytes unchanged, so the override fixes UTF-8 messages read with a non-UTF-8 logOutputEncoding, but not a message stored as EUC-JP.

    339256-before-insiders.mp4

    🤖 Authored with GitHub Copilot on behalf of Ladislau Szomoru (@lszomoru).

  2. added
    bug
    git
    on Nov 23, 2026
  3. added a commit that references this issue on Nov 23, 2026
    7b4ffdd
  4. added
    verified
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buggitverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions