Commit 2bfd289
authored
Fix git diff to compare against HEAD instead of working directory (#1422)
## TL;DR
Changed git diff operations to compare against HEAD instead of the working directory, ensuring we correctly identify staged vs unstaged file changes.
## What changed?
- Modified `getChangedFilesDetailed` function in `packages/git/src/queries.ts` to use `git.diff(["HEAD", "--", file])` instead of `git.diff([file])`
- Added checks to skip files when the diff against HEAD is empty (indicating no changes relative to HEAD)
- Applied this change to both the unstaged changes section and deleted files section of the diff logic
- Wrapped the HEAD diff check in a try-catch block for the deleted files case to handle potential errors gracefully
## How did you test this?
Unable to verify testing details from the provided information.1 parent 17f783b commit 2bfd289
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
502 | | - | |
503 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
504 | 505 | | |
505 | 506 | | |
506 | 507 | | |
| |||
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
528 | 533 | | |
529 | 534 | | |
530 | 535 | | |
| |||
0 commit comments