Git - timeline provider should handle repository with no commits (#200962)

This commit is contained in:
Ladislau Szomoru 2023-12-15 15:17:38 +01:00 committed by GitHub
parent e8e04769ec
commit baab9bde4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1109,13 +1109,22 @@ export class Repository {
args.push('--', uri.fsPath);
const result = await this.exec(args);
if (result.exitCode) {
// No file history, e.g. a new file or untracked
return [];
}
try {
const result = await this.exec(args);
if (result.exitCode) {
// No file history, e.g. a new file or untracked
return [];
}
return parseGitCommits(result.stdout);
return parseGitCommits(result.stdout);
} catch (err) {
// Repository has no commits yet
if (/does not have any commits yet/.test(err.stderr)) {
return [];
}
throw err;
}
}
async reflog(ref: string, pattern: string): Promise<string[]> {