mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
Git - improve handling of first commit (#224165)
This commit is contained in:
@@ -146,13 +146,9 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
||||
|
||||
try {
|
||||
// Get the common ancestor commit, and commits
|
||||
const [mergeBaseCommit, commits] = await Promise.all([
|
||||
this.repository.getCommit(options.limit.id),
|
||||
this.repository.log({ range: `${options.limit.id}..`, refNames, shortStats: true })
|
||||
]);
|
||||
|
||||
// Add common ancestor commit
|
||||
commits.push(mergeBaseCommit);
|
||||
const commit = await this.repository.getCommit(options.limit.id);
|
||||
const commitParentId = commit.parents.length > 0 ? commit.parents[0] : await this.repository.getEmptyTree();
|
||||
const commits = await this.repository.log({ range: `${commitParentId}..`, refNames, shortStats: true });
|
||||
|
||||
await ensureEmojis();
|
||||
|
||||
@@ -180,24 +176,18 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
|
||||
}
|
||||
|
||||
async provideHistoryItemSummary(historyItemId: string, historyItemParentId: string | undefined): Promise<SourceControlHistoryItem> {
|
||||
if (!historyItemParentId) {
|
||||
const commit = await this.repository.getCommit(historyItemId);
|
||||
historyItemParentId = commit.parents.length > 0 ? commit.parents[0] : `${historyItemId}^`;
|
||||
}
|
||||
|
||||
historyItemParentId = historyItemParentId ?? await this.repository.getEmptyTree();
|
||||
const allChanges = await this.repository.diffBetweenShortStat(historyItemParentId, historyItemId);
|
||||
|
||||
return { id: historyItemId, parentIds: [historyItemParentId], message: '', statistics: allChanges };
|
||||
}
|
||||
|
||||
async provideHistoryItemChanges(historyItemId: string, historyItemParentId: string | undefined): Promise<SourceControlHistoryItemChange[]> {
|
||||
if (!historyItemParentId) {
|
||||
const commit = await this.repository.getCommit(historyItemId);
|
||||
historyItemParentId = commit.parents.length > 0 ? commit.parents[0] : `${historyItemId}^`;
|
||||
}
|
||||
historyItemParentId = historyItemParentId ?? await this.repository.getEmptyTree();
|
||||
|
||||
const historyItemChangesUri: Uri[] = [];
|
||||
const historyItemChanges: SourceControlHistoryItemChange[] = [];
|
||||
const changes = await this.repository.diffBetween(historyItemParentId, historyItemId);
|
||||
const changes = await this.repository.diffTrees(historyItemParentId, historyItemId);
|
||||
|
||||
for (const change of changes) {
|
||||
const historyItemUri = change.uri.with({
|
||||
|
||||
Reference in New Issue
Block a user