Skip to content

Commit 38b55df

Browse files
committed
Uses git found by the vscode git extension if available
1 parent 49703f5 commit 38b55df

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/extension.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { Logger } from './logger';
1010
import { Messages } from './messages';
1111
// import { Telemetry } from './telemetry';
1212

13+
interface GitApi {
14+
getGitPath(): Promise<string>;
15+
}
16+
1317
export async function activate(context: ExtensionContext) {
1418
const start = process.hrtime();
1519

@@ -36,7 +40,19 @@ export async function activate(context: ExtensionContext) {
3640
const cfg = configuration.get<IConfig>();
3741

3842
try {
39-
await GitService.initialize(cfg.advanced.git || workspace.getConfiguration('git').get<string>('path'));
43+
let gitPath = cfg.advanced.git;
44+
if (!gitPath) {
45+
// Try to use the same git as the built-in vscode git extension
46+
try {
47+
const gitExtension = extensions.getExtension('vscode.git');
48+
if (gitExtension !== undefined) {
49+
gitPath = await (gitExtension.exports as GitApi).getGitPath();
50+
}
51+
}
52+
catch { }
53+
}
54+
55+
await GitService.initialize(gitPath || workspace.getConfiguration('git').get<string>('path'));
4056
}
4157
catch (ex) {
4258
Logger.error(ex, `GitLens(v${gitlensVersion}).activate`);

0 commit comments

Comments
 (0)