diff --git a/src/git/git.ts b/src/git/git.ts index 5d33f50..dd44ac4 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -802,9 +802,13 @@ export class Git { return data.length === 0 ? undefined : data.trim(); } - static log__search(repoPath: string, search: string[] = emptyArray, { maxCount }: { maxCount?: number } = {}) { - const params = ['log', '--name-status', `--format=${GitLogParser.defaultFormat}`]; - if (maxCount) { + static log__search( + repoPath: string, + search: string[] = emptyArray, + { maxCount, useShow }: { maxCount?: number; useShow?: boolean } = {} + ) { + const params = [useShow ? 'show' : 'log', '--name-status', `--format=${GitLogParser.defaultFormat}`]; + if (maxCount && !useShow) { params.push(`-n${maxCount}`); } diff --git a/src/git/gitService.ts b/src/git/gitService.ts index a7c0cea..69881cf 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -1435,7 +1435,8 @@ export class GitService implements Disposable { search = { matchAll: false, matchCase: false, matchRegex: true, ...search }; try { - let maxCount = options.maxCount == null ? Container.config.advanced.maxSearchItems || 0 : options.maxCount; + const maxCount = + options.maxCount == null ? Container.config.advanced.maxSearchItems || 0 : options.maxCount; const similarityThreshold = Container.config.advanced.similarityThreshold; const operations = GitService.parseSearchOperations(search.pattern); @@ -1443,13 +1444,18 @@ export class GitService implements Disposable { const searchArgs = new Set(); const files: string[] = []; + let useShow = false; + let op; let values = operations.get('commit:'); if (values !== undefined) { + useShow = true; + searchArgs.add('-m'); searchArgs.add(`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`); - searchArgs.add(values[0]); - maxCount = 1; + for (const value of values) { + searchArgs.add(value); + } } else { searchArgs.add(`-M${similarityThreshold == null ? '' : `${similarityThreshold}%`}`); searchArgs.add('--all'); @@ -1503,7 +1509,7 @@ export class GitService implements Disposable { args.push(...files); } - const data = await Git.log__search(repoPath, args, { maxCount: maxCount }); + const data = await Git.log__search(repoPath, args, { maxCount: maxCount, useShow: useShow }); const log = GitLogParser.parse( data, GitCommitType.Log,