Skip to content

Commit a0b9f21

Browse files
tamirohVinzent03
andauthored
Fix diff view issue on smartphones and tablets (#448)
* Fix * Fix * Revert "Fix" This reverts commit b97c972. * Revert "Fix" This reverts commit 986b9aa. * Fix * style: run formatter --------- Co-authored-by: Vinzent <vinzent03@proton.me>
1 parent b059289 commit a0b9f21

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/isomorphicGit.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -972,14 +972,26 @@ export class IsomorphicGit extends GitManager {
972972
const stagedContent = new TextDecoder().decode(stagedBlob);
973973

974974
if (stagedChanges) {
975-
const headBlob = await readBlob({
976-
...this.getRepo(),
977-
filepath: filePath,
978-
oid: await this.resolveRef("HEAD"),
979-
});
980-
const headContent = new TextDecoder().decode(headBlob.blob);
975+
const headContent = await this.resolveRef("HEAD")
976+
.then((oid) =>
977+
readBlob({
978+
...this.getRepo(),
979+
filepath: filePath,
980+
oid: oid,
981+
})
982+
)
983+
.then((headBlob) => new TextDecoder().decode(headBlob.blob))
984+
.catch((err) => {
985+
if (err instanceof git.Errors.NotFoundError)
986+
return undefined;
987+
throw err;
988+
});
981989

982-
const diff = createPatch(filePath, headContent, stagedContent);
990+
const diff = createPatch(
991+
filePath,
992+
headContent ?? "",
993+
stagedContent
994+
);
983995
return diff;
984996
} else {
985997
let workdirContent: string;

0 commit comments

Comments
 (0)