Skip to content

Commit ba79d4a

Browse files
committed
Merge commit 'refs/pull/82995/head' of github.com:microsoft/vscode into pr/82995
2 parents 20a1ce7 + 7b1a6c8 commit ba79d4a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

extensions/git/src/git.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,12 @@ export class Repository {
761761
async log(options?: LogOptions): Promise<Commit[]> {
762762
const maxEntries = options && typeof options.maxEntries === 'number' && options.maxEntries > 0 ? options.maxEntries : 32;
763763
const args = ['log', '-' + maxEntries, `--pretty=format:${COMMIT_FORMAT}%x00%x00`];
764-
const gitResult = await this.run(args);
765-
if (gitResult.exitCode) {
766-
// An empty repo.
764+
765+
let gitResult: IExecutionResult<string>;
766+
try {
767+
gitResult = await this.run(args);
768+
} catch (err) {
769+
// An empty repo
767770
return [];
768771
}
769772

@@ -1163,9 +1166,15 @@ export class Repository {
11631166

11641167
let mode: string;
11651168
let add: string = '';
1169+
let treeish: string = '';
1170+
const commits = await this.log({ maxEntries: 1 });
1171+
1172+
if (commits.length > 0) {
1173+
treeish = 'HEAD';
1174+
}
11661175

11671176
try {
1168-
const details = await this.getObjectDetails('HEAD', path);
1177+
const details = await this.getObjectDetails(treeish, path);
11691178
mode = details.mode;
11701179
} catch (err) {
11711180
if (err.gitErrorCode !== GitErrorCodes.UnknownPath) {

0 commit comments

Comments
 (0)