Skip to content

Commit fdde0bf

Browse files
committed
fix: show diff with custom base path
1 parent 2fa88f3 commit fdde0bf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/isomorphicGit.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,8 @@ export class IsomorphicGit extends GitManager {
951951
filePath: string,
952952
stagedChanges = false
953953
): Promise<string> {
954+
const vaultPath = this.getVaultPath(filePath);
955+
954956
const map: WalkerMap = async (file, [A]) => {
955957
if (filePath == file) {
956958
const oid = await A!.oid();
@@ -988,20 +990,20 @@ export class IsomorphicGit extends GitManager {
988990
});
989991

990992
const diff = createPatch(
991-
filePath,
993+
vaultPath,
992994
headContent ?? "",
993995
stagedContent
994996
);
995997
return diff;
996998
} else {
997999
let workdirContent: string;
998-
if (await app.vault.adapter.exists(filePath)) {
999-
workdirContent = await app.vault.adapter.read(filePath);
1000+
if (await app.vault.adapter.exists(vaultPath)) {
1001+
workdirContent = await app.vault.adapter.read(vaultPath);
10001002
} else {
10011003
workdirContent = "";
10021004
}
10031005

1004-
const diff = createPatch(filePath, stagedContent, workdirContent);
1006+
const diff = createPatch(vaultPath, stagedContent, workdirContent);
10051007
return diff;
10061008
}
10071009
}

0 commit comments

Comments
 (0)