Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3244,7 +3244,11 @@ export class Repository {

async getDefaultBranch(remoteName: string): Promise<Branch> {
const result = await this.exec(['symbolic-ref', '--short', `refs/remotes/${remoteName}/HEAD`]);
if (!result.stdout || result.stderr) {
// Some ssh configurations (e.g. `VisualHostKey yes`) print an ASCII-art host
// key fingerprint on stderr while the command still succeeds, so rely on the
// non-zero exit code to surface real errors rather than treating any stderr
// output as failure. See https://github.com/microsoft/vscode/issues/247862.
if (!result.stdout) {
throw new Error('No default branch');
}

Expand Down Expand Up @@ -3344,11 +3348,11 @@ export class Repository {

async revList(ref1: string, ref2: string): Promise<string[]> {
const result = await this.exec(['rev-list', `${ref1}..${ref2}`]);
if (result.stderr) {
return [];
}

return result.stdout.trim().split('\n');
// Do not treat stderr content as failure: ssh may emit non-error output
// (e.g. `VisualHostKey yes` ASCII-art fingerprints) alongside a zero exit
// code. See https://github.com/microsoft/vscode/issues/247862.
const stdout = result.stdout.trim();
return stdout ? stdout.split('\n') : [];
}

async revParse(ref: string): Promise<string | undefined> {
Expand All @@ -3361,10 +3365,10 @@ export class Repository {

try {
const result = await this.exec(['rev-parse', ref]);
if (result.stderr) {
return undefined;
}
return result.stdout.trim();
// Do not treat stderr content as failure: ssh may emit non-error output
// (e.g. `VisualHostKey yes` ASCII-art fingerprints) alongside a zero exit
// code. See https://github.com/microsoft/vscode/issues/247862.
return result.stdout.trim() || undefined;
} catch (err) {
return undefined;
}
Expand Down