Browse Source

Fixes #1176 - ensures default lines of context

main
Eric Amodio 4 years ago
parent
commit
2dc949b6c3
3 changed files with 20 additions and 11 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +16
    -8
      src/git/git.ts
  3. +3
    -3
      src/git/gitService.ts

+ 1
- 0
CHANGELOG.md View File

@ -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

+ 16
- 8
src/git/git.ts View File

@ -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)}`);

+ 3
- 3
src/git/gitService.ts View File

@ -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;
@ -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,
});
// }

Loading…
Cancel
Save