Skip to content

Commit cdf398f

Browse files
committed
Closes #2877 adds setting to cache git path
1 parent 4d2e632 commit cdf398f

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1111
- Adds Holiday promotion
1212
- Adds the ability to get autolinks for branches via the branch name — closes [#3547](https://github.com/gitkraken/vscode-gitlens/issues/3547)
1313
- Adds GitLab issues to the issues list in the _Start Work_ command when GitLab is connected — closes [#3779](https://github.com/gitkraken/vscode-gitlens/issues/3779)
14+
- Adds `gitlens.advanced.caching.gitPath` setting to specify whether to cache the git path — closes [#2877](https://github.com/gitkraken/vscode-gitlens/issues/2877)
1415

1516
### Changed
1617

17-
- Updates prep-release reference - Thanks to [PR #3732](https://github.com/gitkraken/vscode-gitlens/pull/3732) by Emmanuel Ferdman ([@emmanuel-ferdman](https://github.com/emmanuel-ferdman))
18+
- Updates prep-release reference — thanks to [PR #3732](https://github.com/gitkraken/vscode-gitlens/pull/3732) by Emmanuel Ferdman ([@emmanuel-ferdman](https://github.com/emmanuel-ferdman))
1819

1920
## [16.0.4] - 2024-11-25
2021

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4945,6 +4945,13 @@
49454945
"scope": "window",
49464946
"order": 90
49474947
},
4948+
"gitlens.advanced.caching.gitPath": {
4949+
"type": "boolean",
4950+
"default": true,
4951+
"markdownDescription": "Specifies whether to cache (per-workspace) the path to the Git executable to use for GitLens",
4952+
"scope": "window",
4953+
"order": 91
4954+
},
49484955
"gitlens.debug": {
49494956
"type": "boolean",
49504957
"default": false,

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export interface AdvancedConfig {
181181
};
182182
readonly caching: {
183183
readonly enabled: boolean;
184+
readonly gitPath: boolean;
184185
};
185186
readonly commitOrdering: 'date' | 'author-date' | 'topo' | null;
186187
readonly externalDiffTool: string | null;

src/env/node/git/localGitProvider.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,10 @@ export class LocalGitProvider implements GitProvider, Disposable {
444444
}
445445
void subscribeToScmOpenCloseRepository.call(this);
446446

447-
const potentialGitPaths = configuration.getCore('git.path') ?? this.container.storage.getWorkspace('gitPath');
447+
const canCacheGitPath = configuration.get('advanced.caching.gitPath');
448+
const potentialGitPaths =
449+
configuration.getCore('git.path') ??
450+
(canCacheGitPath ? this.container.storage.getWorkspace('gitPath') : undefined);
448451

449452
const start = hrtime();
450453

@@ -467,7 +470,13 @@ export class LocalGitProvider implements GitProvider, Disposable {
467470

468471
const location = await any<GitLocation>(findGitPromise, findGitFromSCMPromise);
469472
// Save the found git path, but let things settle first to not impact startup performance
470-
setTimeout(() => void this.container.storage.storeWorkspace('gitPath', location.path).catch(), 1000);
473+
setTimeout(
474+
() =>
475+
void this.container.storage
476+
.storeWorkspace('gitPath', canCacheGitPath ? location.path : undefined)
477+
.catch(),
478+
1000,
479+
);
471480

472481
if (scope != null) {
473482
setLogScopeExit(

0 commit comments

Comments
 (0)