Skip to content

Commit 917bef4

Browse files
committed
fix(git): compare against HEAD instead of working directory in diff
1 parent 39e0faf commit 917bef4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/git/src/queries.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,9 @@ export async function getChangedFilesDetailed(
499499
continue;
500500
}
501501
try {
502-
const unstaged = await git.diff([file]);
503-
const lines = unstaged.split("\n");
502+
const headDiff = await git.diff(["HEAD", "--", file]);
503+
if (!headDiff.trim()) continue;
504+
const lines = headDiff.split("\n");
504505
const linesAdded = lines.filter(
505506
(l) => l.startsWith("+") && !l.startsWith("+++"),
506507
).length;
@@ -525,6 +526,10 @@ export async function getChangedFilesDetailed(
525526
) {
526527
continue;
527528
}
529+
try {
530+
const headDiff = await git.diff(["HEAD", "--", file]);
531+
if (!headDiff.trim()) continue;
532+
} catch {}
528533
files.push({
529534
path: file,
530535
status: "deleted",

0 commit comments

Comments
 (0)