Skip to content

Commit

Permalink
fix: show diff with custom base path
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Mar 7, 2023
1 parent 2fa88f3 commit fdde0bf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/isomorphicGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ export class IsomorphicGit extends GitManager {
filePath: string,
stagedChanges = false
): Promise<string> {
const vaultPath = this.getVaultPath(filePath);

const map: WalkerMap = async (file, [A]) => {
if (filePath == file) {
const oid = await A!.oid();
Expand Down Expand Up @@ -988,20 +990,20 @@ export class IsomorphicGit extends GitManager {
});

const diff = createPatch(
filePath,
vaultPath,
headContent ?? "",
stagedContent
);
return diff;
} else {
let workdirContent: string;
if (await app.vault.adapter.exists(filePath)) {
workdirContent = await app.vault.adapter.read(filePath);
if (await app.vault.adapter.exists(vaultPath)) {
workdirContent = await app.vault.adapter.read(vaultPath);
} else {
workdirContent = "";
}

const diff = createPatch(filePath, stagedContent, workdirContent);
const diff = createPatch(vaultPath, stagedContent, workdirContent);
return diff;
}
}
Expand Down

0 comments on commit fdde0bf

Please sign in to comment.