Commit 5fab49c
committed
Fix grepdiff -s/--status to show correct file status indicators
The grepdiff -s option was incorrectly showing '!' (modification) for
all matching files, regardless of whether they were additions,
deletions, or modifications.
The issue was that grepdiff calls display_filename() from inside
do_unified() and do_context() when it finds a matching line, but the
status variable was always initialized to '!' and never updated based
on file existence.
This fix calculates the correct status (+/-/!) inside do_unified() and
do_context() just before calling display_filename(), using:
- orig_file_exists/new_file_exists to check if files exist
- orig_is_empty/new_is_empty to check for empty files when
--empty-files-as-absent is used
The fix applies to both unified and context diff formats.
All 194 tests pass (188 pass + 6 expected failures).
Assisted-by: Claude Code1 parent 398eafa commit 5fab49c
1 file changed
+40
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
672 | 691 | | |
673 | 692 | | |
674 | | - | |
| 693 | + | |
675 | 694 | | |
676 | 695 | | |
677 | 696 | | |
| |||
1018 | 1037 | | |
1019 | 1038 | | |
1020 | 1039 | | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1021 | 1059 | | |
1022 | 1060 | | |
1023 | | - | |
| 1061 | + | |
1024 | 1062 | | |
1025 | 1063 | | |
1026 | 1064 | | |
| |||
0 commit comments