Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust git.cwd to use a relative path to git root #733

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/gitManager/simpleGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { spawnSync } from "child_process";
import debug from "debug";
import { FileSystemAdapter, normalizePath, Notice } from "obsidian";
import * as path from "path";
import { sep } from "path";
import { sep, resolve } from "path";
import simpleGit, * as simple from "simple-git";
import { GIT_LINE_AUTHORING_MOVEMENT_DETECTION_MINIMAL_LENGTH } from "src/constants";
import { LineAuthorFollowMovement } from "src/lineAuthor/model";
Expand Down Expand Up @@ -65,7 +65,11 @@ export class SimpleGit extends GitManager {

debug.enable("simple-git");
if (await this.git.checkIsRepo()) {
await this.git.cwd(await this.git.revparse("--show-toplevel"));
// Resolve the relative root reported by git into an absolute path
// in case git resides in a different filesystem (eg, WSL)
const relativeRoot = await this.git.revparse("--show-cdup");
const absoluteRoot = resolve(basePath + sep + relativeRoot);
await this.git.cwd(absoluteRoot);
}
}
}
Expand Down
Loading