Skip to content

Commit

Permalink
fix: Adjust git.cwd to use a relative path to git root (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
H3mul authored Jun 19, 2024
1 parent a0416ed commit ed31553
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit ed31553

Please sign in to comment.