mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Git - improve handling of first commit (#224165)
This commit is contained in:
@@ -718,6 +718,8 @@ export class Repository implements Disposable {
|
||||
private _untrackedGroup: SourceControlResourceGroup;
|
||||
get untrackedGroup(): GitResourceGroup { return this._untrackedGroup as GitResourceGroup; }
|
||||
|
||||
private _EMPTY_TREE: string | undefined;
|
||||
|
||||
private _HEAD: Branch | undefined;
|
||||
get HEAD(): Branch | undefined {
|
||||
return this._HEAD;
|
||||
@@ -1112,6 +1114,10 @@ export class Repository implements Disposable {
|
||||
return this.run(Operation.Diff, () => this.repository.diffBetweenShortStat(ref1, ref2));
|
||||
}
|
||||
|
||||
diffTrees(treeish1: string, treeish2?: string): Promise<Change[]> {
|
||||
return this.run(Operation.Diff, () => this.repository.diffTrees(treeish1, treeish2));
|
||||
}
|
||||
|
||||
getMergeBase(ref1: string, ref2: string, ...refs: string[]): Promise<string | undefined> {
|
||||
return this.run(Operation.MergeBase, () => this.repository.getMergeBase(ref1, ref2, ...refs));
|
||||
}
|
||||
@@ -1602,6 +1608,15 @@ export class Repository implements Disposable {
|
||||
return await this.repository.getCommit(ref);
|
||||
}
|
||||
|
||||
async getEmptyTree(): Promise<string> {
|
||||
if (!this._EMPTY_TREE) {
|
||||
const result = await this.repository.exec(['hash-object', '-t', 'tree', '/dev/null']);
|
||||
this._EMPTY_TREE = result.stdout.trim();
|
||||
}
|
||||
|
||||
return this._EMPTY_TREE;
|
||||
}
|
||||
|
||||
async getCommitCount(range: string): Promise<{ ahead: number; behind: number }> {
|
||||
return await this.run(Operation.RevList, () => this.repository.getCommitCount(range));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user