瀏覽代碼

Increases threshold to avoid extra queries

Adds extra HEAD check to avoid extra lookup
main
Eric Amodio 2 年之前
父節點
當前提交
a07e85fa7e
共有 2 個文件被更改,包括 17 次插入5 次删除
  1. +5
    -0
      src/env/node/git/git.ts
  2. +12
    -5
      src/env/node/git/localGitProvider.ts

+ 5
- 0
src/env/node/git/git.ts 查看文件

@ -1210,6 +1210,11 @@ export class Git {
return result;
}
async rev_parse(repoPath: string, ref: string): Promise<string | undefined> {
const data = await this.git<string>({ cwd: repoPath, errors: GitErrorHandling.Ignore }, 'rev-parse', ref);
return data.length === 0 ? undefined : data.trim();
}
async rev_parse__currentBranch(
repoPath: string,
ordering: 'date' | 'author-date' | 'topo' | null,

+ 12
- 5
src/env/node/git/localGitProvider.ts 查看文件

@ -1614,8 +1614,13 @@ export class LocalGitProvider implements GitProvider, Disposable {
let stdin: string | undefined;
// // TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
const stash = await this.getStash(repoPath);
const [stashResult, headResult] = await Promise.allSettled([
this.getStash(repoPath),
options?.ref != null && options.ref !== 'HEAD' ? this.git.rev_parse(repoPath, 'HEAD') : undefined,
]);
// TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
const stash = getSettledValue(stashResult);
if (stash != null) {
stdin = join(
map(stash.commits.values(), c => c.sha.substring(0, 9)),
@ -1625,6 +1630,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
let getLogForRefFn;
if (options?.ref != null) {
const head = getSettledValue(headResult);
async function getLogForRef(this: LocalGitProvider): Promise<GitLog | undefined> {
let log;
@ -1637,7 +1644,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
let found = false;
// If we are looking for the HEAD assume that it might be in the first page (so we can avoid extra queries)
if (options!.ref === 'HEAD') {
if (options!.ref === 'HEAD' || options!.ref === head) {
log = await this.getLog(repoPath, {
all: options!.mode !== 'single',
ordering: 'date',
@ -1665,11 +1672,11 @@ export class LocalGitProvider implements GitProvider, Disposable {
debugger;
}
if (log?.more != null && (!found || log.commits.size < defaultItemLimit)) {
if (log?.more != null && (!found || log.commits.size < defaultItemLimit / 2)) {
Logger.debug(scope, 'Loading next page...');
log = await log.more(
(log.commits.size < defaultItemLimit
(found && log.commits.size < defaultItemLimit / 2
? defaultItemLimit
: configuration.get('graph.pageItemLimit')) ?? options?.limit,
);

Loading…
取消
儲存