Kaynağa Gözat

Fixes #1438 - wrong encoding for diffs

main
Eric Amodio 3 yıl önce
ebeveyn
işleme
34792752d9
3 değiştirilmiş dosya ile 10 ekleme ve 10 silme
  1. +1
    -0
      CHANGELOG.md
  2. +6
    -7
      src/git/git.ts
  3. +3
    -3
      src/git/shell.ts

+ 1
- 0
CHANGELOG.md Dosyayı Görüntüle

@ -65,6 +65,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [1438](https://github.com/eamodio/vscode-gitlens/issues/1438) - Messages in hovers wrong encoding using non UTF-8
- Fixes [1372](https://github.com/eamodio/vscode-gitlens/issues/1372) - Unexpected repository detection on editor startup after recent updates
- Fixes [1394](https://github.com/eamodio/vscode-gitlens/issues/1394) - Repository view settings appear disabled
- Fixes [1391](https://github.com/eamodio/vscode-gitlens/issues/1391) - Branch names are not properly escaped in git commands

+ 6
- 7
src/git/git.ts Dosyayı Görüntüle

@ -63,7 +63,7 @@ export enum GitErrorHandling {
Throw = 'throw',
}
export interface GitCommandOptions extends RunOptions {
export interface GitCommandOptions extends RunOptions<BufferEncoding | 'buffer' | string> {
configs?: string[];
readonly correlationKey?: string;
errors?: GitErrorHandling;
@ -89,12 +89,11 @@ export async function git(options: GitCommandOptio
const start = process.hrtime();
const { configs, correlationKey, errors: errorHandling, ...opts } = options;
const { configs, correlationKey, errors: errorHandling, encoding, ...opts } = options;
const encoding = options.encoding ?? 'utf8';
const runOpts: RunOptions = {
...opts,
encoding: encoding === 'utf8' ? 'utf8' : encoding === 'buffer' ? 'buffer' : 'binary',
encoding: (encoding ?? 'utf8') === 'utf8' ? 'utf8' : 'buffer',
// Adds GCM environment variables to avoid any possible credential issues -- from https://github.com/Microsoft/vscode/issues/26573#issuecomment-338686581
// Shouldn't *really* be needed but better safe than sorry
env: {
@ -131,7 +130,7 @@ export async function git(options: GitCommandOptio
args.splice(0, 0, '-c', 'core.longpaths=true');
}
promise = run<TOut>(gitInfo.path, args, encoding, runOpts);
promise = run<TOut>(gitInfo.path, args, encoding ?? 'utf8', runOpts);
pendingCommands.set(command, promise);
} else {
@ -525,7 +524,7 @@ export namespace Git {
{
cwd: repoPath,
configs: ['-c', 'color.diff=false'],
encoding: options.encoding === 'utf8' ? 'utf8' : 'binary',
encoding: options.encoding,
},
...params,
'--',
@ -578,7 +577,7 @@ export namespace Git {
{
cwd: repoPath,
configs: ['-c', 'color.diff=false'],
encoding: options.encoding === 'utf8' ? 'utf8' : 'binary',
encoding: options.encoding,
stdin: contents,
},
...params,

+ 3
- 3
src/git/shell.ts Dosyayı Görüntüle

@ -114,10 +114,10 @@ export function findExecutable(exe: string, args: string[]): { cmd: string; args
return { cmd: exe, args: args };
}
export interface RunOptions {
export interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {
cwd?: string;
readonly env?: Record<string, any>;
readonly encoding?: BufferEncoding | 'buffer';
readonly encoding?: TEncoding;
/**
* The size the output buffer to allocate to the spawned process. Set this
* if you are anticipating a large amount of output.
@ -174,7 +174,7 @@ export class RunError extends Error {
export function run<TOut extends string | Buffer>(
command: string,
args: any[],
encoding: BufferEncoding | 'buffer',
encoding: BufferEncoding | 'buffer' | string,
options: RunOptions = {},
): Promise<TOut> {
const { stdin, stdinEncoding, ...opts }: RunOptions = { maxBuffer: 100 * 1024 * 1024, ...options };

Yükleniyor…
İptal
Kaydet