Skip to content

Commit

Permalink
Fixes #1176 - ensures default lines of context
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 30, 2020
1 parent 6c6cf52 commit 2dc949b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- Fixes [#1176](https://github.com/eamodio/vscode-gitlens/issues/1176) - Can't selectively apply stash
- Fixes [#1212](https://github.com/eamodio/vscode-gitlens/issues/1212) - Stashes list doesn't refresh on deletion
- Fixes [#1191](https://github.com/eamodio/vscode-gitlens/issues/1191) - "Gitlens › Views › Repositories: Auto Refresh" not working
- Fixes [#1202](https://github.com/eamodio/vscode-gitlens/issues/1202) - "Copy Remote File Url" url-encodes the URL
Expand Down
24 changes: 16 additions & 8 deletions src/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,23 @@ export namespace Git {
fileName: string,
ref1?: string,
ref2?: string,
options: { encoding?: string; filters?: GitDiffFilter[]; similarityThreshold?: number | null } = {},
options: {
encoding?: string;
filters?: GitDiffFilter[];
linesOfContext?: number;
renames?: boolean;
similarityThreshold?: number | null;
} = {},
): Promise<string> {
const params = [
'diff',
`-M${options.similarityThreshold == null ? '' : `${options.similarityThreshold}%`}`,
'--no-ext-diff',
'-U0',
'--minimal',
];
const params = ['diff', '--no-ext-diff', '--minimal'];

if (options.linesOfContext != null) {
params.push(`-U${options.linesOfContext}`);
}

if (options.renames) {
params.push(`-M${options.similarityThreshold == null ? '' : `${options.similarityThreshold}%`}`);
}

if (options.filters != null && options.filters.length !== 0) {
params.push(`--diff-filter=${options.filters.join(emptyStr)}`);
Expand Down
6 changes: 3 additions & 3 deletions src/git/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,7 @@ export class GitService implements Disposable {

let patch;
try {
patch = await Git.diff(uri.repoPath, uri.fsPath, ref1, ref2, {
similarityThreshold: Container.config.advanced.similarityThreshold,
});
patch = await Git.diff(uri.repoPath, uri.fsPath, ref1, ref2);
void (await Git.apply(uri.repoPath, patch));
} catch (ex) {
const msg: string = ex?.toString() ?? emptyStr;
Expand Down Expand Up @@ -1524,6 +1522,8 @@ export class GitService implements Disposable {
const data = await Git.diff(root, file, ref1, ref2, {
...options,
filters: ['M'],
linesOfContext: 0,
renames: true,
similarityThreshold: Container.config.advanced.similarityThreshold,
});
// }
Expand Down

0 comments on commit 2dc949b

Please sign in to comment.