feat(compare): implement Document Compare dialog with local-diff and git-HEAD-diff modes

Amit Haridas
This commit is contained in:
2026-08-23 19:31:33 +05:30
parent 1f5db511ba
commit 758dcb4166
10 changed files with 769 additions and 3 deletions
+7 -1
View File
@@ -41,9 +41,15 @@ async function log(dir, maxCount = 20) {
}
}
async function diff(dir, file) {
// againstHead=true compares the working tree (staged + unstaged) against the last
// commit instead of against the index — used by the Document Compare dialog's
// "Git HEAD" mode. Default behavior (worktree vs index) is unchanged.
async function diff(dir, file, againstHead = false) {
try {
const git = getGitInstance(dir);
if (againstHead) {
return file ? await git.diff(['HEAD', '--', file]) : await git.diff('HEAD');
}
return file ? await git.diff([file]) : await git.diff();
} catch (err) {
return { error: err.message };