Skip to content

Commit efcc3ca

Browse files
committed
Fixes #2482 lazy loads files for merge commits
Consolidated log into log2 calls (and renames it)
1 parent 32a3f64 commit efcc3ca

File tree

7 files changed

+63
-121
lines changed

7 files changed

+63
-121
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fixes [#2482](https://github.com/gitkraken/vscode-gitlens/issues/2482) - Unresponsive "commits" view and "branches" view update due to git log
12+
913
## [14.5.1] - 2023-11-21
1014

1115
### Added

src/env/node/git/git.ts

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,85 +1082,6 @@ export class Git {
10821082
}
10831083

10841084
log(
1085-
repoPath: string,
1086-
ref: string | undefined,
1087-
{
1088-
all,
1089-
argsOrFormat,
1090-
authors,
1091-
limit,
1092-
merges,
1093-
ordering,
1094-
similarityThreshold,
1095-
since,
1096-
until,
1097-
}: {
1098-
all?: boolean;
1099-
argsOrFormat?: string | string[];
1100-
authors?: GitUser[];
1101-
limit?: number;
1102-
merges?: boolean;
1103-
ordering?: 'date' | 'author-date' | 'topo' | null;
1104-
similarityThreshold?: number | null;
1105-
since?: number | string;
1106-
until?: number | string;
1107-
},
1108-
) {
1109-
if (argsOrFormat == null) {
1110-
argsOrFormat = ['--name-status', `--format=${all ? parseGitLogAllFormat : parseGitLogDefaultFormat}`];
1111-
}
1112-
1113-
if (typeof argsOrFormat === 'string') {
1114-
argsOrFormat = [`--format=${argsOrFormat}`];
1115-
}
1116-
1117-
const params = [
1118-
'log',
1119-
...argsOrFormat,
1120-
'--full-history',
1121-
`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`,
1122-
'-m',
1123-
];
1124-
1125-
if (ordering) {
1126-
params.push(`--${ordering}-order`);
1127-
}
1128-
1129-
if (limit) {
1130-
params.push(`-n${limit + 1}`);
1131-
}
1132-
1133-
if (since) {
1134-
params.push(`--since="${since}"`);
1135-
}
1136-
1137-
if (until) {
1138-
params.push(`--until="${until}"`);
1139-
}
1140-
1141-
if (!merges) {
1142-
params.push('--first-parent');
1143-
}
1144-
1145-
if (authors != null && authors.length !== 0) {
1146-
if (!params.includes('--use-mailmap')) {
1147-
params.push('--use-mailmap');
1148-
}
1149-
params.push(...authors.map(a => `--author=^${a.name} <${a.email}>$`));
1150-
}
1151-
1152-
if (all) {
1153-
params.push('--all', '--single-worktree');
1154-
}
1155-
1156-
if (ref && !isUncommittedStaged(ref)) {
1157-
params.push(ref);
1158-
}
1159-
1160-
return this.git<string>({ cwd: repoPath, configs: gitLogDefaultConfigsWithFiles }, ...params, '--');
1161-
}
1162-
1163-
log2(
11641085
repoPath: string,
11651086
options?: {
11661087
cancellation?: CancellationToken;

src/env/node/git/localGitProvider.ts

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
22672267
const statsParser = getGraphStatsParser();
22682268

22692269
const [refResult, stashResult, branchesResult, remotesResult, currentUserResult] = await Promise.allSettled([
2270-
this.git.log2(repoPath, undefined, ...refParser.arguments, '-n1', options?.ref ?? 'HEAD'),
2270+
this.git.log(repoPath, undefined, ...refParser.arguments, '-n1', options?.ref ?? 'HEAD'),
22712271
this.getStash(repoPath),
22722272
this.getBranches(repoPath),
22732273
this.getRemotes(repoPath),
@@ -2339,7 +2339,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
23392339
} else {
23402340
args.push(`-n${nextPageLimit + 1}`);
23412341

2342-
data = await this.git.log2(repoPath, stdin ? { stdin: stdin } : undefined, ...args);
2342+
data = await this.git.log(repoPath, stdin ? { stdin: stdin } : undefined, ...args);
23432343

23442344
if (cursor) {
23452345
if (!getShaInLogRegex(cursor.sha).test(data)) {
@@ -2727,7 +2727,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
27272727
}
27282728
args.push(`--${ordering}-order`, '--all');
27292729

2730-
const statsData = await this.git.log2(repoPath, stdin ? { stdin: stdin } : undefined, ...args);
2730+
const statsData = await this.git.log(repoPath, stdin ? { stdin: stdin } : undefined, ...args);
27312731
if (statsData) {
27322732
const commitStats = statsParser.parse(statsData);
27332733
for (const stat of commitStats) {
@@ -2810,10 +2810,12 @@ export class LocalGitProvider implements GitProvider, Disposable {
28102810
const currentUser = await this.getCurrentUser(repoPath);
28112811
const parser = getContributorsParser(options?.stats);
28122812

2813-
const data = await this.git.log(repoPath, options?.ref, {
2814-
all: options?.all,
2815-
argsOrFormat: parser.arguments,
2816-
});
2813+
const args = [...parser.arguments, '--full-history', '--first-parent'];
2814+
if (options?.all) {
2815+
args.push('--all', '--single-worktree');
2816+
}
2817+
2818+
const data = await this.git.log(repoPath, { ref: options?.ref }, ...args);
28172819

28182820
const contributors = new Map<string, GitContributor>();
28192821

@@ -3320,14 +3322,10 @@ export class LocalGitProvider implements GitProvider, Disposable {
33203322

33213323
try {
33223324
const limit = options?.limit ?? configuration.get('advanced.maxListItems') ?? 0;
3323-
const merges = options?.merges == null ? true : options.merges;
3324-
const ordering = options?.ordering ?? configuration.get('advanced.commitOrdering');
33253325
const similarityThreshold = configuration.get('advanced.similarityThreshold');
3326-
33273326
const args = [
33283327
`--format=${options?.all ? parseGitLogAllFormat : parseGitLogDefaultFormat}`,
33293328
`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`,
3330-
'-m',
33313329
];
33323330

33333331
if (options?.status !== null) {
@@ -3336,11 +3334,19 @@ export class LocalGitProvider implements GitProvider, Disposable {
33363334
if (options?.all) {
33373335
args.push('--all');
33383336
}
3339-
if (!merges) {
3337+
3338+
const merges = options?.merges ?? true;
3339+
if (merges) {
3340+
if (limit <= 2) {
3341+
// Ensure we return the merge commit files when we are asking for a specific ref
3342+
args.push('-m');
3343+
}
3344+
args.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');
3345+
} else {
33403346
args.push('--no-merges');
3341-
} else if (merges === 'first-parent') {
3342-
args.push('--first-parent');
33433347
}
3348+
3349+
const ordering = options?.ordering ?? configuration.get('advanced.commitOrdering');
33443350
if (ordering) {
33453351
args.push(`--${ordering}-order`);
33463352
}
@@ -3374,7 +3380,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
33743380
args.push(`-n${limit + 1}`);
33753381
}
33763382

3377-
const data = await this.git.log2(
3383+
const data = await this.git.log(
33783384
repoPath,
33793385
{ configs: gitLogDefaultConfigsWithFiles, ref: options?.ref, stdin: options?.stdin },
33803386
...args,
@@ -3437,8 +3443,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
34373443
if (log.hasMore) {
34383444
let opts;
34393445
if (options != null) {
3440-
let extraArgs;
3441-
({ extraArgs, ...opts } = options);
3446+
let _;
3447+
({ extraArgs: _, ...opts } = options);
34423448
}
34433449
log.more = this.getLogMoreFn(log, opts);
34443450
}
@@ -3459,7 +3465,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
34593465
authors?: GitUser[];
34603466
cursor?: string;
34613467
limit?: number;
3462-
merges?: boolean;
3468+
merges?: boolean | 'first-parent';
34633469
ordering?: 'date' | 'author-date' | 'topo' | null;
34643470
ref?: string;
34653471
since?: string;
@@ -3471,16 +3477,36 @@ export class LocalGitProvider implements GitProvider, Disposable {
34713477

34723478
try {
34733479
const parser = createLogParserSingle('%H');
3480+
const args = [...parser.arguments, '--full-history'];
34743481

3475-
const data = await this.git.log(repoPath, options?.ref, {
3476-
authors: options?.authors,
3477-
argsOrFormat: parser.arguments,
3478-
limit: limit,
3479-
merges: options?.merges == null ? true : options.merges,
3480-
similarityThreshold: configuration.get('advanced.similarityThreshold'),
3481-
since: options?.since,
3482-
ordering: options?.ordering ?? configuration.get('advanced.commitOrdering'),
3483-
});
3482+
const ordering = options?.ordering ?? configuration.get('advanced.commitOrdering');
3483+
if (ordering) {
3484+
args.push(`--${ordering}-order`);
3485+
}
3486+
3487+
if (limit) {
3488+
args.push(`-n${limit + 1}`);
3489+
}
3490+
3491+
if (options?.since) {
3492+
args.push(`--since="${options.since}"`);
3493+
}
3494+
3495+
const merges = options?.merges ?? true;
3496+
if (merges) {
3497+
args.push(merges === 'first-parent' ? '--first-parent' : '--no-min-parents');
3498+
} else {
3499+
args.push('--no-merges');
3500+
}
3501+
3502+
if (options?.authors?.length) {
3503+
if (!args.includes('--use-mailmap')) {
3504+
args.push('--use-mailmap');
3505+
}
3506+
args.push(...options.authors.map(a => `--author=^${a.name} <${a.email}>$`));
3507+
}
3508+
3509+
const data = await this.git.log(repoPath, { ref: options?.ref }, ...args);
34843510

34853511
const commits = new Set(parser.parse(data));
34863512
return commits;
@@ -5304,7 +5330,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
53045330

53055331
let data;
53065332
try {
5307-
data = await this.git.log2(
5333+
data = await this.git.log(
53085334
repoPath,
53095335
{
53105336
cancellation: options?.cancellation,

src/git/gitProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export interface GitProvider extends Disposable {
346346
authors?: GitUser[] | undefined;
347347
cursor?: string | undefined;
348348
limit?: number | undefined;
349-
merges?: boolean | undefined;
349+
merges?: boolean | 'first-parent';
350350
ordering?: 'date' | 'author-date' | 'topo' | null | undefined;
351351
ref?: string | undefined;
352352
since?: string | undefined;

src/git/gitProviderService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ export class GitProviderService implements Disposable {
18841884
options?: {
18851885
authors?: GitUser[];
18861886
limit?: number;
1887-
merges?: boolean;
1887+
merges?: boolean | 'first-parent';
18881888
ordering?: 'date' | 'author-date' | 'topo' | null;
18891889
ref?: string;
18901890
since?: string;

src/git/parsers/logParser.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,6 @@ export function parseGitLog(
527527

528528
let hasFiles = true;
529529
if (next.done || next.value === '</f>') {
530-
// If this is a merge commit and there are no files returned, skip the commit and reduce our truncationCount to ensure accurate truncation detection
531-
if ((entry.parentShas?.length ?? 0) > 1) {
532-
if (truncationCount) {
533-
truncationCount--;
534-
}
535-
536-
break;
537-
}
538-
539530
hasFiles = false;
540531
}
541532

src/plus/integrations/providers/github/githubGitProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
17821782
authors?: GitUser[];
17831783
cursor?: string;
17841784
limit?: number;
1785-
merges?: boolean;
1785+
merges?: boolean | 'first-parent';
17861786
ordering?: 'date' | 'author-date' | 'topo' | null;
17871787
ref?: string;
17881788
since?: string;
@@ -1887,7 +1887,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
18871887
authors?: GitUser[];
18881888
cursor?: string;
18891889
limit?: number;
1890-
merges?: boolean;
1890+
merges?: boolean | 'first-parent';
18911891
ordering?: 'date' | 'author-date' | 'topo' | null;
18921892
ref?: string;
18931893
since?: string;
@@ -1905,7 +1905,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
19051905
options?: {
19061906
authors?: GitUser[];
19071907
limit?: number;
1908-
merges?: boolean;
1908+
merges?: boolean | 'first-parent';
19091909
ordering?: 'date' | 'author-date' | 'topo' | null;
19101910
ref?: string;
19111911
},

0 commit comments

Comments
 (0)