Skip to content

Commit

Permalink
Fixes #454 - Avoids merge commits for file/change searches
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 22, 2018
1 parent dae8cfb commit 89523f7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
- Fixes [#454](https://github.com/eamodio/vscode-gitlens/issues/454) - Search for string returns merge commits (unlike raw `git log -S`)

## [8.5.2] - 2018-07-20
### Fixed
- Fixes [#451](https://github.com/eamodio/vscode-gitlens/issues/451) - "apply Changes" has discarded all my changes
Expand Down
14 changes: 7 additions & 7 deletions src/commands/showCommitSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
const searchByRegex = /^([@~=:#])/;
const searchByMap = new Map<string, GitRepoSearchBy>([
['@', GitRepoSearchBy.Author],
['~', GitRepoSearchBy.Changes],
['=', GitRepoSearchBy.ChangedOccurrences],
['~', GitRepoSearchBy.ChangedLines],
['=', GitRepoSearchBy.Changes],
[':', GitRepoSearchBy.Files],
['#', GitRepoSearchBy.Sha]
]);
Expand Down Expand Up @@ -65,7 +65,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
args.search = await window.showInputBox({
value: args.search,
prompt: `Please enter a search string`,
placeHolder: `search by message, author (@<pattern>), files (:<pattern>), commit id (#<sha>), changes (~<pattern>), or changed occurrences (=<string>)`
placeHolder: `search by message, author (@<pattern>), files (:<pattern>), commit id (#<sha>), changes (=<pattern>), changed lines (~<pattern>)`
} as InputBoxOptions);
if (args.search === undefined) {
return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
Expand Down Expand Up @@ -96,12 +96,12 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
searchLabel = `commits with an author matching '${args.search}'`;
break;

case GitRepoSearchBy.Changes:
searchLabel = `commits with changes matching '${args.search}'`;
case GitRepoSearchBy.ChangedLines:
searchLabel = `commits with changed lines matching '${args.search}'`;
break;

case GitRepoSearchBy.ChangedOccurrences:
searchLabel = `commits with changed occurrences matching '${args.search}'`;
case GitRepoSearchBy.Changes:
searchLabel = `commits with changes matching '${args.search}'`;
break;

case GitRepoSearchBy.Files:
Expand Down
2 changes: 1 addition & 1 deletion src/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export class Git {
}

static log_search(repoPath: string, search: string[] = [], options: { maxCount?: number } = {}) {
const params = [...defaultLogParams, '-M', '-m', '-i'];
const params = [...defaultLogParams];
if (options.maxCount) {
params.push(`-n${options.maxCount}`);
}
Expand Down
19 changes: 11 additions & 8 deletions src/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const RepoSearchWarnings = {

export enum GitRepoSearchBy {
Author = 'author',
ChangedOccurrences = 'changed-occurrences',
ChangedLines = 'changed-lines',
Changes = 'changes',
Files = 'files',
Message = 'message',
Expand Down Expand Up @@ -1151,22 +1151,25 @@ export class GitService extends Disposable {
let searchArgs: string[] | undefined = undefined;
switch (searchBy) {
case GitRepoSearchBy.Author:
searchArgs = [`--author=${search}`];
searchArgs = ['-m', '-M', '--all', '--full-history', '-i', `--author=${search}`];
break;
case GitRepoSearchBy.ChangedOccurrences:
searchArgs = [`-S${search}`, '--pickaxe-regex'];
case GitRepoSearchBy.ChangedLines:
searchArgs = ['-M', '--all', '--full-history', '-i', `-G${search}`];
break;
case GitRepoSearchBy.Changes:
searchArgs = [`-G${search}`];
searchArgs = ['-M', '--all', '--full-history', '-i', '--pickaxe-regex', `-S${search}`];
break;
case GitRepoSearchBy.Files:
searchArgs = [`--`, `${search}`];
searchArgs = ['-M', '--all', '--full-history', '-i', `--`, `${search}`];
break;
case GitRepoSearchBy.Message:
searchArgs = search ? [`--grep=${search}`] : [];
searchArgs = ['-m', '-M', '--all', '--full-history'];
if (search) {
searchArgs.push(`--grep=${search}`);
}
break;
case GitRepoSearchBy.Sha:
searchArgs = [search];
searchArgs = [`-m`, '-M', search];
maxCount = 1;
break;
}
Expand Down

0 comments on commit 89523f7

Please sign in to comment.