diff --git a/Makefile.am b/Makefile.am index 9b901524..b9381400 100644 --- a/Makefile.am +++ b/Makefile.am @@ -315,6 +315,7 @@ TESTS = tests/newline1/run-test \ tests/git-rename-issue22/run-test \ tests/git-binary-issue57/run-test \ tests/git-binary-formats/run-test \ + tests/git-extended-diffs-exclude/run-test \ tests/git-mode-issue59/run-test \ tests/git-exclude-issue27/run-test \ tests/git-prefixes-option/run-test \ diff --git a/NEWS b/NEWS index 59d61936..8251dd64 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,17 @@ Patchutils news 0.4.5 (stable) + Reverted incompatible behavior change from version 0.4.4. In 0.4.4, + Git diffs without content hunks (renames, copies, mode-only changes, + binary files) were included in output and file numbering, breaking + compatibility with 0.4.3 and earlier versions. This caused file numbers + to change for scripts using -N/-F options. The 0.4.3 behavior has been + restored as the default: these diffs are now excluded from output and + numbering. Added --git-extended-diffs option to control this behavior: + use --git-extended-diffs=include to get the 0.4.4 behavior if needed. + The default will change to 'include' in version 0.5.0 for modern Git + workflow support. Addresses GitHub issue #157. + Fixed grepdiff -s/--status to display correct file status indicators. Previously, grepdiff -s incorrectly showed '!' (modification) for all matching files regardless of whether they were additions, deletions, diff --git a/doc/patchutils.xml b/doc/patchutils.xml index 27bbb1dc..fb95cacb 100644 --- a/doc/patchutils.xml +++ b/doc/patchutils.xml @@ -592,6 +592,7 @@ --strip=n --git-prefixes=strip|keep + --git-extended-diffs=exclude|include --addprefix=PREFIX --addoldprefix=PREFIX --addnewprefix=PREFIX @@ -799,6 +800,17 @@ in version 0.5.0. + + =exclude|include + + Controls whether to process Git diffs without traditional content hunks. + This includes renames, copies, mode-only changes, and binary files. + With exclude (default in 0.4.x), these diffs are + skipped. With include (default in 0.5.0+), these + diffs are processed normally. This option affects file numbering with + and file filtering with . + + =PREFIX @@ -1078,6 +1090,7 @@ patch.file]]> --strip=n --git-prefixes=strip|keep + --git-extended-diffs=exclude|include --addprefix=PREFIX --addoldprefix=PREFIX --addnewprefix=PREFIX @@ -1264,6 +1277,17 @@ patch.file]]> in version 0.5.0. + + =exclude|include + + Controls whether to process Git diffs without traditional content hunks. + This includes renames, copies, mode-only changes, and binary files. + With exclude (default in 0.4.x), these diffs are + skipped. With include (default in 0.5.0+), these + diffs are processed normally. This option affects file numbering with + and file filtering with . + + =PREFIX @@ -1457,6 +1481,7 @@ done)]]> --strip=n --git-prefixes=strip|keep + --git-extended-diffs=exclude|include --addprefix=PREFIX -s @@ -1666,6 +1691,17 @@ This is the same as gitdiff but uses git show instead of git diff. in version 0.5.0. + + =exclude|include + + Controls whether to process Git diffs without traditional content hunks. + This includes renames, copies, mode-only changes, and binary files. + With exclude (default in 0.4.x), these diffs are + skipped. With include (default in 0.5.0+), these + diffs are processed normally. This option affects file numbering with + and file filtering with . + + =PREFIX @@ -2050,6 +2086,7 @@ This is the same as gitdiff but uses git show instead of git diff. --strip=n --git-prefixes=strip|keep + --git-extended-diffs=exclude|include --addprefix=PREFIX --addoldprefix=PREFIX --addnewprefix=PREFIX @@ -2199,6 +2236,17 @@ This is the same as gitdiff but uses git show instead of git diff. in version 0.5.0. + + =exclude|include + + Controls whether to process Git diffs without traditional content hunks. + This includes renames, copies, mode-only changes, and binary files. + With exclude (default in 0.4.x), these diffs are + skipped. With include (default in 0.5.0+), these + diffs are processed normally. This option affects file numbering with + and file filtering with . + + =PREFIX diff --git a/src/filterdiff.c b/src/filterdiff.c index c7fb1326..e722a91d 100644 --- a/src/filterdiff.c +++ b/src/filterdiff.c @@ -112,6 +112,33 @@ static unsigned long filecount=0; static enum git_prefix_mode git_prefix_mode = GIT_PREFIX_KEEP; +enum git_extended_diffs_mode { + GIT_EXTENDED_DIFFS_EXCLUDE = 0, /* Skip extended diffs (0.4.3 behavior) */ + GIT_EXTENDED_DIFFS_INCLUDE = 1 /* Process extended diffs (Git workflow) */ +}; + +static enum git_extended_diffs_mode git_extended_diffs_mode = GIT_EXTENDED_DIFFS_EXCLUDE; + +/* Helper function to check if a git diff type should be excluded based on mode */ +static int +should_skip_git_extended_diff (enum git_diff_type git_type) +{ + if (git_extended_diffs_mode == GIT_EXTENDED_DIFFS_INCLUDE) + return 0; /* Don't skip anything if include mode */ + + /* In exclude mode, skip all diffs without content hunks. + * This includes renames, copies, mode-only changes, binary files, + * and new/deleted files without content (e.g., binary files). + * This restores 0.4.3 behavior where only files with actual + * patch hunks were shown. */ + switch (git_type) { + case GIT_DIFF_NORMAL: + return 0; /* Don't skip - has hunks */ + default: + return 1; /* Skip all extended/special types */ + } +} + /* Helper function to check if current patch is a Git patch */ static int is_git_patch (char **headers, unsigned int num_headers) @@ -1314,7 +1341,11 @@ static int filterdiff (FILE *f, const char *patchname) /* Process as git diff without hunks and then exit */ enum git_diff_type git_type = detect_git_diff_type (header, num_headers); - if (git_type != GIT_DIFF_NORMAL) { + + /* Skip extended diffs if in exclude mode */ + if (should_skip_git_extended_diff (git_type)) + goto eof; + if (git_type != GIT_DIFF_NORMAL) { char *git_old_name = NULL, *git_new_name = NULL; const char *p_stripped; int match; @@ -1391,7 +1422,11 @@ static int filterdiff (FILE *f, const char *patchname) /* Check if this is a git diff without hunks or with content like Binary files */ enum git_diff_type git_type = detect_git_diff_type (header, num_headers); - if (git_type != GIT_DIFF_NORMAL) { + + /* Skip extended diffs if in exclude mode */ + if (should_skip_git_extended_diff (git_type)) + goto flush_continue; + if (git_type != GIT_DIFF_NORMAL) { /* This is a git diff without hunks - handle it */ char *git_old_name = NULL, *git_new_name = NULL; const char *p_stripped; @@ -1633,6 +1668,9 @@ const char * syntax_str = " --git-prefixes=strip|keep\n" " how to handle a/ and b/ prefixes in Git diffs for both filename\n" " matching (-i/-x) and output (default: keep)\n" +" --git-extended-diffs=exclude|include\n" +" process Git diffs without hunks: renames, copies, mode-only\n" +" changes, binary files; default is exclude\n" " --addprefix=PREFIX\n" " prefix pathnames with PREFIX\n" " --addoldprefix=PREFIX\n" @@ -1893,6 +1931,7 @@ int main (int argc, char *argv[]) {"file", 1, 0, 'f'}, {"in-place", 0, 0, 1000 + 'w'}, {"git-prefixes", 1, 0, 1000 + 'G'}, + {"git-extended-diffs", 1, 0, 1000 + 'D'}, {0, 0, 0, 0} }; char *end; @@ -2085,6 +2124,15 @@ int main (int argc, char *argv[]) error(EXIT_FAILURE, 0, "invalid argument to --git-prefixes: %s (expected 'strip' or 'keep')", optarg); } break; + case 1000 + 'D': + if (!strcmp(optarg, "exclude")) { + git_extended_diffs_mode = GIT_EXTENDED_DIFFS_EXCLUDE; + } else if (!strcmp(optarg, "include")) { + git_extended_diffs_mode = GIT_EXTENDED_DIFFS_INCLUDE; + } else { + error(EXIT_FAILURE, 0, "invalid argument to --git-extended-diffs: %s (expected 'exclude' or 'include')", optarg); + } + break; default: syntax(1); } diff --git a/tests/filterdiff-binary-filtering/run-test b/tests/filterdiff-binary-filtering/run-test index 2052aaa0..8cef01e8 100755 --- a/tests/filterdiff-binary-filtering/run-test +++ b/tests/filterdiff-binary-filtering/run-test @@ -26,7 +26,8 @@ Binary files /dev/null and b/file2.bin differ EOF # Test -F2: should only show file #2 (file1.bin), NOT file2.bin -${FILTERDIFF} -F2 diff 2>errors >output || exit 1 +# Note: using --git-extended-diffs=include to test binary file filtering +${FILTERDIFF} --git-extended-diffs=include -F2 diff 2>errors >output || exit 1 [ -s errors ] && exit 1 cat << 'EOF' | cmp - output || exit 1 diff --git a/tests/git-binary-formats/run-test b/tests/git-binary-formats/run-test index 7b76dd3b..8c8a5b56 100755 --- a/tests/git-binary-formats/run-test +++ b/tests/git-binary-formats/run-test @@ -62,7 +62,7 @@ EOF # Test filtering binary files with GIT binary patch format - should include binary content echo "Testing GIT binary patch format (include)..." -${FILTERDIFF} --git-prefixes=strip -i "file1.bin" git-binary-patch.patch 2>errors1 >result1 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file1.bin" git-binary-patch.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && { echo "Unexpected errors in test 1:"; cat errors1; exit 1; } cat << 'EOF' | cmp - result1 || { echo "Test 1 failed"; exit 1; } @@ -78,7 +78,7 @@ EOF # Test filtering binary files with literal format - should include binary content echo "Testing literal format (include)..." -${FILTERDIFF} --git-prefixes=strip -i "file3.bin" literal-patch.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file3.bin" literal-patch.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && { echo "Unexpected errors in test 2:"; cat errors2; exit 1; } cat << 'EOF' | cmp - result2 || { echo "Test 2 failed"; exit 1; } @@ -93,7 +93,7 @@ EOF # Test filtering binary files with delta format - should include binary content echo "Testing delta format (include)..." -${FILTERDIFF} --git-prefixes=strip -i "file5.bin" delta-patch.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file5.bin" delta-patch.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && { echo "Unexpected errors in test 3:"; cat errors3; exit 1; } cat << 'EOF' | cmp - result3 || { echo "Test 3 failed"; exit 1; } @@ -108,7 +108,7 @@ EOF # Test excluding binary files - should skip binary content echo "Testing binary patch exclusion..." -${FILTERDIFF} --git-prefixes=strip -x "file1.bin" git-binary-patch.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x "file1.bin" git-binary-patch.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && { echo "Unexpected errors in test 4:"; cat errors4; exit 1; } cat << 'EOF' | cmp - result4 || { echo "Test 4 failed"; exit 1; } diff --git a/tests/git-binary-issue57/run-test b/tests/git-binary-issue57/run-test index bdc99fe7..45d7c9cc 100755 --- a/tests/git-binary-issue57/run-test +++ b/tests/git-binary-issue57/run-test @@ -21,7 +21,7 @@ index 0000000..abcdefg EOF # Test that filterdiff includes binary files when they match -${FILTERDIFF} --git-prefixes=strip -i binary-file git-binary.patch 2>errors >result || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i binary-file git-binary.patch 2>errors >result || exit 1 [ -s errors ] && exit 1 cat << EOF | cmp - result || exit 1 @@ -32,7 +32,7 @@ Binary files /dev/null and b/binary-file differ EOF # Test that lsdiff shows binary files -${LSDIFF} --git-prefixes=strip git-binary.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip git-binary.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -41,7 +41,7 @@ text-file.txt EOF # Test excluding binary files -${FILTERDIFF} --git-prefixes=strip -x binary-file git-binary.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x binary-file git-binary.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 diff --git a/tests/git-complex-mixed/run-test b/tests/git-complex-mixed/run-test index e46619a5..20a70d4f 100755 --- a/tests/git-complex-mixed/run-test +++ b/tests/git-complex-mixed/run-test @@ -65,7 +65,7 @@ index 111222..333444 100644 EOF # Test 1: lsdiff should list all files correctly -${LSDIFF} complex-git.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include complex-git.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 cat << EOF | cmp - result1 || exit 1 @@ -79,7 +79,7 @@ a/regular-change.h EOF # Test 2: lsdiff with --git-prefixes=strip -${LSDIFF} --git-prefixes=strip complex-git.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip complex-git.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -93,7 +93,7 @@ regular-change.h EOF # Test 3: Filter only new files -${FILTERDIFF} -i "*/*.txt" complex-git.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "*/*.txt" complex-git.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 # Should include new-file.txt and new-name.txt (renamed file) @@ -102,7 +102,7 @@ grep -q "new-name.txt" result3 || exit 1 grep -q "binary-data.bin" result3 && exit 1 # Should not include binary # Test 4: Filter binary files specifically -${FILTERDIFF} -i "*/*.bin" complex-git.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "*/*.bin" complex-git.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -113,14 +113,14 @@ Binary files /dev/null and b/binary-data.bin differ EOF # Test 5: Exclude deleted files -${FILTERDIFF} -x "*/*.old" complex-git.patch 2>errors5 >result5 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -x "*/*.old" complex-git.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 # Should not contain deleted-file.old grep -q "deleted-file.old" result5 && exit 1 # Test 6: Test grepdiff on content changes only -${GREPDIFF} "NEW_VERSION" complex-git.patch 2>errors6 >result6 || exit 1 +${GREPDIFF} --git-extended-diffs=include "NEW_VERSION" complex-git.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 # Should only match regular-change.h @@ -128,7 +128,7 @@ grep -q "regular-change.h" result6 || exit 1 grep -q "new-file.txt" result6 && exit 1 # Should not match files without the pattern # Test 7: Test with -p strip on complex paths -${FILTERDIFF} --git-prefixes=strip -p0 --strip=0 complex-git.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -p0 --strip=0 complex-git.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 # Should preserve all content diff --git a/tests/git-copy-operations/run-test b/tests/git-copy-operations/run-test index 9305bfee..2d276439 100755 --- a/tests/git-copy-operations/run-test +++ b/tests/git-copy-operations/run-test @@ -24,7 +24,7 @@ index abc123..def456 100644 EOF # Test lsdiff with copy operation -${LSDIFF} copy-basic.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include copy-basic.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 cat << EOF | cmp - result1 || exit 1 @@ -32,7 +32,7 @@ b/copy1.c EOF # Test filterdiff with copy operation -${FILTERDIFF} -i "b/copy1.c" copy-basic.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "b/copy1.c" copy-basic.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -82,7 +82,7 @@ index 111222..555666 100644 EOF # Test lsdiff with multiple copies -${LSDIFF} copy-multiple.patch 2>errors3 >result3 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include copy-multiple.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 @@ -91,14 +91,14 @@ a/base.h EOF # Test filtering by source file (matches both copies) -${FILTERDIFF} -i "a/base.h" copy-multiple.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "a/base.h" copy-multiple.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 grep -q "copy2.h" result4 || exit 1 grep -q "copy1.h" result4 || exit 1 # Test 3: Copy with --git-prefixes=strip -${LSDIFF} --git-prefixes=strip copy-multiple.patch 2>errors5 >result5 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip copy-multiple.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 cat << EOF | cmp - result5 || exit 1 @@ -115,14 +115,14 @@ copy to backup.bin Binary files a/data.bin and b/backup.bin differ EOF -${LSDIFF} copy-binary.patch 2>errors6 >result6 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include copy-binary.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 a/data.bin EOF -${FILTERDIFF} -i "a/data.bin" copy-binary.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "a/data.bin" copy-binary.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << EOF | cmp - result7 || exit 1 @@ -152,7 +152,7 @@ rename from file2.txt rename to file2-renamed.txt EOF -${LSDIFF} copy-rename-mixed.patch 2>errors8 >result8 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include copy-rename-mixed.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 cat << EOF | cmp - result8 || exit 1 @@ -189,7 +189,7 @@ index abc123..xyz789 100644 } EOF -${FILTERDIFF} copy-low-similarity.patch 2>errors9 >result9 || exit 1 +${FILTERDIFF} --git-extended-diffs=include copy-low-similarity.patch 2>errors9 >result9 || exit 1 [ -s errors9 ] && exit 1 grep -q "heavily-modified.c" result9 || exit 1 diff --git a/tests/git-deleted-file/run-test b/tests/git-deleted-file/run-test index 4bdc95f8..c6ee93e2 100755 --- a/tests/git-deleted-file/run-test +++ b/tests/git-deleted-file/run-test @@ -44,7 +44,7 @@ index 222..0000000 EOF echo "=== Test 1: lsdiff with deleted file ===" -${LSDIFF} --git-prefixes=strip -s git-deleted.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip -s git-deleted.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 # Should show file with '-' status @@ -53,7 +53,7 @@ cat << EOF | cmp - result1 || exit 1 EOF echo "=== Test 2: filterdiff include deleted file ===" -${FILTERDIFF} --git-prefixes=strip -i "deleted*" git-deleted.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "deleted*" git-deleted.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 # Should include the full diff @@ -70,14 +70,14 @@ index abc123..0000000 EOF echo "=== Test 3: filterdiff exclude deleted file ===" -${FILTERDIFF} --git-prefixes=strip -x "deleted*" git-deleted.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x "deleted*" git-deleted.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 # Should be empty [ -s result3 ] && exit 1 echo "=== Test 4: lsdiff with deleted file (no hunks) ===" -${LSDIFF} --git-prefixes=strip -s git-deleted-no-hunks.patch 2>errors4 >result4 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip -s git-deleted-no-hunks.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -85,7 +85,7 @@ cat << EOF | cmp - result4 || exit 1 EOF echo "=== Test 5: filterdiff with deleted file (no hunks) ===" -${FILTERDIFF} --git-prefixes=strip -i "*.c" git-deleted-no-hunks.patch 2>errors5 >result5 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*.c" git-deleted-no-hunks.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 cat << 'EOF' | cmp - result5 || exit 1 @@ -96,7 +96,7 @@ Binary files a/removed.c and /dev/null differ EOF echo "=== Test 6: lsdiff with multiple deleted files ===" -${LSDIFF} --git-prefixes=strip -s git-multiple-deleted.patch 2>errors6 >result6 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip -s git-multiple-deleted.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 @@ -105,7 +105,7 @@ cat << EOF | cmp - result6 || exit 1 EOF echo "=== Test 7: filterdiff with pattern matching multiple deleted files ===" -${FILTERDIFF} --git-prefixes=strip -i "file1*" git-multiple-deleted.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "file1*" git-multiple-deleted.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << 'EOF' | cmp - result7 || exit 1 @@ -119,7 +119,7 @@ index 111..0000000 EOF echo "=== Test 8: Test git-prefixes with deleted files ===" -${LSDIFF} --git-prefixes=strip -s git-deleted.patch 2>errors8 >result8 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip -s git-deleted.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 cat << EOF | cmp - result8 || exit 1 diff --git a/tests/git-diff-duplication/run-test b/tests/git-diff-duplication/run-test index b41cf651..d52a6aa4 100755 --- a/tests/git-diff-duplication/run-test +++ b/tests/git-diff-duplication/run-test @@ -27,7 +27,7 @@ index 1111111..2222222 100644 EOF # Test that filterdiff preserves the output unchanged -${FILTERDIFF} --git-prefixes=strip git-diff-bug.patch 2>errors >result || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip git-diff-bug.patch 2>errors >result || exit 1 [ -s errors ] && exit 1 # The result should be identical to the input diff --git a/tests/git-diff-edge-cases/run-test b/tests/git-diff-edge-cases/run-test index c6661032..c972795a 100755 --- a/tests/git-diff-edge-cases/run-test +++ b/tests/git-diff-edge-cases/run-test @@ -67,7 +67,7 @@ index abc123..abc123 100644 EOF echo "=== Test 1: Mode-only change ===" -${LSDIFF} -s git-mode-only.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-mode-only.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 cat << EOF | cmp - result1 || exit 1 @@ -75,7 +75,7 @@ cat << EOF | cmp - result1 || exit 1 EOF echo "=== Test 2: Binary file with no hunks ===" -${LSDIFF} -s git-binary-no-hunks.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-binary-no-hunks.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -83,7 +83,7 @@ cat << EOF | cmp - result2 || exit 1 EOF echo "=== Test 3: Copy operation ===" -${LSDIFF} -s git-copy.patch 2>errors3 >result3 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-copy.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 @@ -91,7 +91,7 @@ cat << EOF | cmp - result3 || exit 1 EOF echo "=== Test 4: filterdiff with copy operation ===" -${FILTERDIFF} -i "*/copy*" git-copy.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "*/copy*" git-copy.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << 'EOF' | cmp - result4 || exit 1 @@ -110,7 +110,7 @@ index abc123..def456 100644 EOF echo "=== Test 5: filterdiff with copy by target name ===" -${FILTERDIFF} -i "*/copy*" git-copy.patch 2>errors5 >result5 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "*/copy*" git-copy.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 # Should still match (uses best_name) @@ -130,7 +130,7 @@ index abc123..def456 100644 EOF echo "=== Test 6: Malformed git headers fallback ===" -${LSDIFF} malformed-git.patch 2>errors6 >result6 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include malformed-git.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 @@ -138,7 +138,7 @@ a/file.txt EOF echo "=== Test 7: Mode and content change ===" -${LSDIFF} -s git-mode-and-content.patch 2>errors7 >result7 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-mode-and-content.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << EOF | cmp - result7 || exit 1 @@ -146,14 +146,14 @@ cat << EOF | cmp - result7 || exit 1 EOF echo "=== Test 8: Empty git diff ===" -${LSDIFF} -s git-empty.patch 2>errors8 >result8 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-empty.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 # Empty git diff should produce no output [ -s result8 ] && exit 1 echo "=== Test 9: filterdiff with git-prefixes on various types ===" -${FILTERDIFF} --git-prefixes=strip -i "*.sh" git-mode-only.patch 2>errors9 >result9 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*.sh" git-mode-only.patch 2>errors9 >result9 || exit 1 [ -s errors9 ] && exit 1 cat << 'EOF' | cmp - result9 || exit 1 @@ -164,7 +164,7 @@ index abc123..abc123 100644 EOF echo "=== Test 10: Test include/exclude with no matches ===" -${FILTERDIFF} -i "nonexistent*" git-mode-only.patch 2>errors10 >result10 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "nonexistent*" git-mode-only.patch 2>errors10 >result10 || exit 1 [ -s errors10 ] && exit 1 # Should be empty @@ -189,7 +189,7 @@ new mode 100755 index def456..def456 100644 EOF -${LSDIFF} -s mixed-git-types.patch 2>errors11 >result11 || exit 1 +${LSDIFF} --git-extended-diffs=include -s mixed-git-types.patch 2>errors11 >result11 || exit 1 [ -s errors11 ] && exit 1 cat << EOF | cmp - result11 || exit 1 @@ -199,7 +199,7 @@ cat << EOF | cmp - result11 || exit 1 EOF echo "=== Test 12: filterdiff with pattern matching mixed types ===" -${FILTERDIFF} -i "a/*.txt" mixed-git-types.patch 2>errors12 >result12 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "a/*.txt" mixed-git-types.patch 2>errors12 >result12 || exit 1 [ -s errors12 ] && exit 1 cat << 'EOF' | cmp - result12 || exit 1 diff --git a/tests/git-error-handling/run-test b/tests/git-error-handling/run-test index 484a7212..7e5e28dc 100755 --- a/tests/git-error-handling/run-test +++ b/tests/git-error-handling/run-test @@ -17,7 +17,7 @@ index abc123..def456 100644 EOF # Should handle gracefully and treat as regular diff -${FILTERDIFF} malformed1.patch 2>errors1 >result1 || exit 1 +${FILTERDIFF} --git-extended-diffs=include malformed1.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 grep -q "file.txt" result1 || exit 1 @@ -33,7 +33,7 @@ index abc123..def456 100644 EOF # Should handle gracefully -${FILTERDIFF} malformed2.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include malformed2.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 # Test 3: Git diff with only one filename in git line @@ -48,7 +48,7 @@ index abc123..def456 100644 EOF # Should handle gracefully -${FILTERDIFF} malformed3.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include malformed3.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 # Test 4: Git diff with unusual prefixes (not a/ b/) @@ -63,12 +63,12 @@ index abc123..def456 100644 EOF # Should handle gracefully -${FILTERDIFF} unusual-prefixes.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include unusual-prefixes.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 grep -q "file.txt" result4 || exit 1 # Test 5: Test --git-prefixes with unusual prefixes -${FILTERDIFF} --git-prefixes=strip unusual-prefixes.patch 2>errors5 >result5 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip unusual-prefixes.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 grep -q "file.txt" result5 || exit 1 @@ -83,7 +83,7 @@ index abc123..def456 100644 +new EOF -${FILTERDIFF} --git-prefixes=strip no-prefixes.patch 2>errors6 >result6 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip no-prefixes.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 grep -q "file.txt" result6 || exit 1 @@ -95,12 +95,12 @@ index 0000000..1234567 Binary files /dev/null and b/binary.dat differ EOF -${FILTERDIFF} -i "*binary*" git-binary-patch.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "*binary*" git-binary-patch.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 grep -q "binary.dat" result7 || exit 1 # Test 8: Test lsdiff with binary patch format -${LSDIFF} git-binary-patch.patch 2>errors8 >result8 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include git-binary-patch.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 cat << EOF | cmp - result8 || exit 1 @@ -125,7 +125,7 @@ HcmV?d00001 EOF -${LSDIFF} mixed-binary.patch 2>errors9 >result9 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include mixed-binary.patch 2>errors9 >result9 || exit 1 [ -s errors9 ] && exit 1 cat << EOF | cmp - result9 || exit 1 @@ -142,7 +142,7 @@ index 0000000..e69de29 +++ b/empty.txt EOF -${FILTERDIFF} empty-git.patch 2>errors10 >result10 || exit 1 +${FILTERDIFF} --git-extended-diffs=include empty-git.patch 2>errors10 >result10 || exit 1 [ -s errors10 ] && exit 1 # Empty patch should produce no output [ ! -s result10 ] || exit 1 diff --git a/tests/git-exclude-issue27/run-test b/tests/git-exclude-issue27/run-test index f8ec26f4..c04f87d4 100755 --- a/tests/git-exclude-issue27/run-test +++ b/tests/git-exclude-issue27/run-test @@ -24,7 +24,7 @@ index 1234567..abcdefg 100644 EOF # Test that excluding README.vin removes the entire git diff block -${FILTERDIFF} --git-prefixes=strip -x README.vin git-multi.patch 2>errors >result || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x README.vin git-multi.patch 2>errors >result || exit 1 [ -s errors ] && exit 1 # The result should contain the complete autogen.sh diff, no orphaned headers @@ -39,7 +39,7 @@ index 1234567..abcdefg 100644 EOF # Test that excluding both files results in empty output -${FILTERDIFF} --git-prefixes=strip -x README.vin -x autogen.sh git-multi.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x README.vin -x autogen.sh git-multi.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 # The result should be completely empty diff --git a/tests/git-extended-diffs-exclude/run-test b/tests/git-extended-diffs-exclude/run-test new file mode 100755 index 00000000..b86d5fd7 --- /dev/null +++ b/tests/git-extended-diffs-exclude/run-test @@ -0,0 +1,168 @@ +#!/bin/sh + +# Test for --git-extended-diffs=exclude option +# Verifies that exclude mode matches 0.4.3 behavior by skipping +# git diffs without content hunks (renames, copies, mode-only, binary files) + +. ${top_srcdir-.}/tests/common.sh + +cat << EOF > mixed-git.patch +diff --git a/1-rename.txt b/1-rename-new.txt +similarity index 100% +rename from 1-rename.txt +rename to 1-rename-new.txt +diff --git a/2-copy.c b/2-copy-new.c +similarity index 95% +copy from 2-copy.c +copy to 2-copy-new.c +diff --git a/3-mode-only.sh b/3-mode-only.sh +old mode 100755 +new mode 100644 +diff --git a/4-binary.bin b/4-binary.bin +new file mode 100644 +index 0000000..998a95d +Binary files /dev/null and b/4-binary.bin differ +diff --git a/5-normal.txt b/5-normal.txt +--- a/5-normal.txt ++++ b/5-normal.txt +@@ -1 +1 @@ +-old ++new +diff --git a/6-another.txt b/6-another.txt +--- a/6-another.txt ++++ b/6-another.txt +@@ -1 +1 @@ +-old ++new +EOF + +# Test 1: Default should be exclude in 0.4.x (only show files with hunks) +${LSDIFF} mixed-git.patch 2>errors1 >result1 || exit 1 +[ -s errors1 ] && exit 1 + +cat << EOF | cmp - result1 || exit 1 +a/5-normal.txt +a/6-another.txt +EOF + +# Test 2: Explicit --git-extended-diffs=exclude +${LSDIFF} --git-extended-diffs=exclude mixed-git.patch 2>errors2 >result2 || exit 1 +[ -s errors2 ] && exit 1 + +cat << EOF | cmp - result2 || exit 1 +a/5-normal.txt +a/6-another.txt +EOF + +# Test 3: File numbering with exclude mode +${LSDIFF} -N --git-extended-diffs=exclude mixed-git.patch 2>errors3 >result3 || exit 1 +[ -s errors3 ] && exit 1 + +cat << EOF | cmp - result3 || exit 1 +File #1 a/5-normal.txt +File #2 a/6-another.txt +EOF + +# Test 4: filterdiff with exclude mode +${FILTERDIFF} --git-extended-diffs=exclude -i "*normal*" mixed-git.patch 2>errors4 >result4 || exit 1 +[ -s errors4 ] && exit 1 + +cat << EOF | cmp - result4 || exit 1 +diff --git a/5-normal.txt b/5-normal.txt +--- a/5-normal.txt ++++ b/5-normal.txt +@@ -1 +1 @@ +-old ++new +EOF + +# Test 5: File number filtering works with exclude mode +${FILTERDIFF} --git-extended-diffs=exclude -F 2 mixed-git.patch 2>errors5 >result5 || exit 1 +[ -s errors5 ] && exit 1 + +cat << EOF | cmp - result5 || exit 1 +diff --git a/6-another.txt b/6-another.txt +--- a/6-another.txt ++++ b/6-another.txt +@@ -1 +1 @@ +-old ++new +EOF + +# Test 6: Compare with include mode (should show all files) +${LSDIFF} -N --git-extended-diffs=include mixed-git.patch 2>errors6 >result6 || exit 1 +[ -s errors6 ] && exit 1 + +cat << EOF | cmp - result6 || exit 1 +File #1 a/1-rename.txt +File #2 a/2-copy.c +File #3 a/3-mode-only.sh +File #4 a/4-binary.bin +File #5 a/5-normal.txt +File #6 a/6-another.txt +EOF + +# Test 7: Coverage for GIT_DIFF_NORMAL case in should_skip_git_extended_diff() +# Normal git diffs should NOT be skipped in exclude mode +cat << EOF > normal-only.patch +diff --git a/file.txt b/file.txt +--- a/file.txt ++++ b/file.txt +@@ -1,3 +1,3 @@ + line 1 +-old line ++new line + line 3 +EOF + +${FILTERDIFF} --git-extended-diffs=exclude normal-only.patch 2>errors7 >result7 || exit 1 +[ -s errors7 ] && exit 1 + +cat << EOF | cmp - result7 || exit 1 +diff --git a/file.txt b/file.txt +--- a/file.txt ++++ b/file.txt +@@ -1,3 +1,3 @@ + line 1 +-old line ++new line + line 3 +EOF + +# Test 8: Coverage for goto eof path when extended diff at EOF +# Patch ending with extended diff should skip to eof in exclude mode +cat << EOF > eof.patch +diff --git a/normal.txt b/normal.txt +--- a/normal.txt ++++ b/normal.txt +@@ -1 +1 @@ +-old ++new +diff --git a/rename.txt b/rename-new.txt +similarity index 100% +rename from rename.txt +rename to rename-new.txt +EOF + +${FILTERDIFF} --git-extended-diffs=exclude eof.patch 2>errors8 >result8 || exit 1 +[ -s errors8 ] && exit 1 + +# Should only show normal diff, not the rename at EOF +cat << EOF | cmp - result8 || exit 1 +diff --git a/normal.txt b/normal.txt +--- a/normal.txt ++++ b/normal.txt +@@ -1 +1 @@ +-old ++new +EOF + +# Test 9: Coverage for invalid argument error path +# Invalid argument to --git-extended-diffs should error +${FILTERDIFF} --git-extended-diffs=invalid mixed-git.patch 2>errors9 >result9 && exit 1 + +# Check error message +grep -q "invalid argument to --git-extended-diffs" errors9 || exit 1 +grep -q "expected 'exclude' or 'include'" errors9 || exit 1 + +exit 0 diff --git a/tests/git-extended-headers/run-test b/tests/git-extended-headers/run-test index b012a5e6..71b49278 100755 --- a/tests/git-extended-headers/run-test +++ b/tests/git-extended-headers/run-test @@ -18,14 +18,14 @@ index 1234567..0000000 -line 3 EOF -${LSDIFF} --git-prefixes=strip deleted-file.patch 2>errors1a >result1a || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip deleted-file.patch 2>errors1a >result1a || exit 1 [ -s errors1a ] && exit 1 cat << EOF | cmp - result1a || exit 1 removed.txt EOF -${FILTERDIFF} --git-prefixes=strip -i "removed.txt" deleted-file.patch 2>errors1a2 >result1a2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "removed.txt" deleted-file.patch 2>errors1a2 >result1a2 || exit 1 [ -s errors1a2 ] && exit 1 cat << EOF | cmp - result1a2 || exit 1 @@ -47,14 +47,14 @@ deleted file mode 100644 index e69de29..0000000 EOF -${LSDIFF} --git-prefixes=strip deleted-file-no-hunks.patch 2>errors1b >result1b || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip deleted-file-no-hunks.patch 2>errors1b >result1b || exit 1 [ -s errors1b ] && exit 1 cat << EOF | cmp - result1b || exit 1 empty-deleted.txt EOF -${FILTERDIFF} --git-prefixes=strip -i "empty-deleted.txt" deleted-file-no-hunks.patch 2>errors1b2 >result1b2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "empty-deleted.txt" deleted-file-no-hunks.patch 2>errors1b2 >result1b2 || exit 1 [ -s errors1b2 ] && exit 1 cat << EOF | cmp - result1b2 || exit 1 @@ -76,14 +76,14 @@ index 0000000..abcdefg +new line 3 EOF -${LSDIFF} --git-prefixes=strip new-file.patch 2>errors2a >result2a || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip new-file.patch 2>errors2a >result2a || exit 1 [ -s errors2a ] && exit 1 cat << EOF | cmp - result2a || exit 1 created.txt EOF -${FILTERDIFF} --git-prefixes=strip -i "created.txt" new-file.patch 2>errors2a2 >result2a2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "created.txt" new-file.patch 2>errors2a2 >result2a2 || exit 1 [ -s errors2a2 ] && exit 1 cat << EOF | cmp - result2a2 || exit 1 @@ -105,14 +105,14 @@ new file mode 100644 index 0000000..e69de29 EOF -${LSDIFF} --git-prefixes=strip new-file-no-hunks.patch 2>errors2b >result2b || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip new-file-no-hunks.patch 2>errors2b >result2b || exit 1 [ -s errors2b ] && exit 1 cat << EOF | cmp - result2b || exit 1 empty-new.txt EOF -${FILTERDIFF} --git-prefixes=strip -i "empty-new.txt" new-file-no-hunks.patch 2>errors2b2 >result2b2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "empty-new.txt" new-file-no-hunks.patch 2>errors2b2 >result2b2 || exit 1 [ -s errors2b2 ] && exit 1 cat << EOF | cmp - result2b2 || exit 1 @@ -129,14 +129,14 @@ index e69de29..0000000 Binary files a/pure-deleted.txt and /dev/null differ EOF -${LSDIFF} --git-prefixes=strip deleted-file-binary.patch 2>errors1c >result1c || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip deleted-file-binary.patch 2>errors1c >result1c || exit 1 [ -s errors1c ] && exit 1 cat << EOF | cmp - result1c || exit 1 pure-deleted.txt EOF -${FILTERDIFF} --git-prefixes=strip -i "pure-deleted.txt" deleted-file-binary.patch 2>errors1c2 >result1c2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "pure-deleted.txt" deleted-file-binary.patch 2>errors1c2 >result1c2 || exit 1 [ -s errors1c2 ] && exit 1 cat << EOF | cmp - result1c2 || exit 1 @@ -181,14 +181,14 @@ index abc1234..def5678 100644 +} EOF -${LSDIFF} --git-prefixes=strip dissimilar-file.patch 2>errors3a >result3a || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip dissimilar-file.patch 2>errors3a >result3a || exit 1 [ -s errors3a ] && exit 1 cat << EOF | cmp - result3a || exit 1 rewritten.c EOF -${FILTERDIFF} --git-prefixes=strip -i "rewritten.c" dissimilar-file.patch 2>errors3a2 >result3a2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "rewritten.c" dissimilar-file.patch 2>errors3a2 >result3a2 || exit 1 [ -s errors3a2 ] && exit 1 grep -q "dissimilarity index 95%" result3a2 || exit 1 @@ -288,7 +288,7 @@ index old123..new456 100644 EOF # Test lsdiff shows all files -${LSDIFF} --git-prefixes=strip mixed-extended.patch 2>errors4 >result4 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip mixed-extended.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -301,19 +301,19 @@ completely-rewritten.java EOF # Test filtering works with all header types -${FILTERDIFF} --git-prefixes=strip -i "*.py" mixed-extended.patch 2>errors5 >result5 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*.py" mixed-extended.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 grep -q "brand-new.py" result5 || exit 1 grep -q "new file mode 100755" result5 || exit 1 -${FILTERDIFF} --git-prefixes=strip -i "*.java" mixed-extended.patch 2>errors6 >result6 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*.java" mixed-extended.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 grep -q "completely-rewritten.java" result6 || exit 1 grep -q "dissimilarity index 98%" result6 || exit 1 -${FILTERDIFF} --git-prefixes=strip -i "old.txt" mixed-extended.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "old.txt" mixed-extended.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 grep -q "deleted file mode 100644" result7 || exit 1 @@ -337,7 +337,7 @@ index abc123..def456 100755 printf("Hello"); EOF -${FILTERDIFF} --git-prefixes=strip -i "*complex*.c" multiple-headers.patch 2>errors8 >result8 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*complex*.c" multiple-headers.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 grep -q "similarity index 75%" result8 || exit 1 diff --git a/tests/git-lsdiff-complex/run-test b/tests/git-lsdiff-complex/run-test index ecc4572b..f9c9733d 100755 --- a/tests/git-lsdiff-complex/run-test +++ b/tests/git-lsdiff-complex/run-test @@ -48,7 +48,7 @@ index abc123..def456 100644 +new line EOF -${LSDIFF} -s all-types-mixed.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include -s all-types-mixed.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 cat << EOF | cmp - result1 || exit 1 @@ -68,7 +68,7 @@ index 0000000..abc123 Binary files /dev/null and b/new-binary.bin differ EOF -${LSDIFF} -s binary-new-file.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include -s binary-new-file.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -83,7 +83,7 @@ index abc123..0000000 Binary files a/old-binary.bin and /dev/null differ EOF -${LSDIFF} -s binary-deleted-file.patch 2>errors3 >result3 || exit 1 +${LSDIFF} --git-extended-diffs=include -s binary-deleted-file.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 @@ -101,7 +101,7 @@ delta 456 zcmV-;0E~(b0jh^H8Gi-<0001b0000000000000000000000000000000000 EOF -${LSDIFF} -s binary-modified.patch 2>errors4 >result4 || exit 1 +${LSDIFF} --git-extended-diffs=include -s binary-modified.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -120,7 +120,7 @@ index 0000000..abc123 +echo "hello" EOF -${LSDIFF} -s new-file-with-mode.patch 2>errors5 >result5 || exit 1 +${LSDIFF} --git-extended-diffs=include -s new-file-with-mode.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 cat << EOF | cmp - result5 || exit 1 @@ -155,7 +155,7 @@ index abc123..def456 100644 +} EOF -${LSDIFF} -s rename-low-similarity.patch 2>errors6 >result6 || exit 1 +${LSDIFF} --git-extended-diffs=include -s rename-low-similarity.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 @@ -171,7 +171,7 @@ copy to instance.h index abc123..abc123 100644 EOF -${LSDIFF} -s copy-identical.patch 2>errors7 >result7 || exit 1 +${LSDIFF} --git-extended-diffs=include -s copy-identical.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << EOF | cmp - result7 || exit 1 @@ -199,7 +199,7 @@ index 789abc..def789 100644 +new EOF -${LSDIFF} -s multiple-modes.patch 2>errors8 >result8 || exit 1 +${LSDIFF} --git-extended-diffs=include -s multiple-modes.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 cat << EOF | cmp - result8 || exit 1 @@ -209,7 +209,7 @@ cat << EOF | cmp - result8 || exit 1 EOF # Test 9: Test with filterdiff --list mode (should use same code paths) -${FILTERDIFF} --list -s all-types-mixed.patch 2>errors9 >result9 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --list -s all-types-mixed.patch 2>errors9 >result9 || exit 1 [ -s errors9 ] && exit 1 # Should be identical to lsdiff -s output diff --git a/tests/git-lsdiff-status/run-test b/tests/git-lsdiff-status/run-test index d4117d2b..df2216f9 100755 --- a/tests/git-lsdiff-status/run-test +++ b/tests/git-lsdiff-status/run-test @@ -11,7 +11,7 @@ new file mode 100644 index 0000000..abcdef1 EOF -${LSDIFF} -s new-file-no-hunks.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include -s new-file-no-hunks.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 cat << EOF | cmp - result1 || exit 1 @@ -25,7 +25,7 @@ deleted file mode 100644 index abcdef1..0000000 EOF -${LSDIFF} -s deleted-file-no-hunks.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include -s deleted-file-no-hunks.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -45,7 +45,7 @@ index 0000000..1234567 +line 3 EOF -${LSDIFF} -s new-file-with-hunks.patch 2>errors3 >result3 || exit 1 +${LSDIFF} --git-extended-diffs=include -s new-file-with-hunks.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 @@ -65,7 +65,7 @@ index 1234567..0000000 -line 3 EOF -${LSDIFF} -s deleted-file-with-hunks.patch 2>errors4 >result4 || exit 1 +${LSDIFF} --git-extended-diffs=include -s deleted-file-with-hunks.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -78,7 +78,7 @@ diff --git a/modified-file.txt b/modified-file.txt index abcdef1..1234567 100644 EOF -${LSDIFF} -s modified-file-no-hunks.patch 2>errors5 >result5 || exit 1 +${LSDIFF} --git-extended-diffs=include -s modified-file-no-hunks.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 # Should produce no output (empty file) @@ -97,7 +97,7 @@ index abcdef1..1234567 100644 line 3 EOF -${LSDIFF} -s modified-file-with-hunks.patch 2>errors6 >result6 || exit 1 +${LSDIFF} --git-extended-diffs=include -s modified-file-with-hunks.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 @@ -135,7 +135,7 @@ deleted file mode 100644 index e69de29..0000000 EOF -${LSDIFF} -s mixed-git.patch 2>errors7 >result7 || exit 1 +${LSDIFF} --git-extended-diffs=include -s mixed-git.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << EOF | cmp - result7 || exit 1 @@ -147,7 +147,7 @@ cat << EOF | cmp - result7 || exit 1 EOF # Test 8: Test with filterdiff in list mode (should use same code paths) -${FILTERDIFF} --list -s mixed-git.patch 2>errors8 >result8 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --list -s mixed-git.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 # Should be identical to lsdiff -s output diff --git a/tests/git-mode-issue59/run-test b/tests/git-mode-issue59/run-test index 46680e10..9bed1d89 100755 --- a/tests/git-mode-issue59/run-test +++ b/tests/git-mode-issue59/run-test @@ -23,7 +23,7 @@ new mode 100644 EOF # Test that filterdiff includes mode-only changes when they match -${FILTERDIFF} --git-prefixes=strip -i mode-only.sh git-mode.patch 2>errors >result || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i mode-only.sh git-mode.patch 2>errors >result || exit 1 [ -s errors ] && exit 1 cat << EOF | cmp - result || exit 1 @@ -33,7 +33,7 @@ new mode 100644 EOF # Test that lsdiff shows both files (one with content, one mode-only) -${LSDIFF} --git-prefixes=strip git-mode.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip git-mode.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -42,7 +42,7 @@ mode-only.sh EOF # Test including files with content changes -${FILTERDIFF} --git-prefixes=strip -i script.sh git-mode.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i script.sh git-mode.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 diff --git a/tests/git-prefixes-option/run-test b/tests/git-prefixes-option/run-test index c18f2a90..96047574 100755 --- a/tests/git-prefixes-option/run-test +++ b/tests/git-prefixes-option/run-test @@ -33,7 +33,7 @@ index abcdefg..1234567 100644 EOF # Test default behavior (keep prefixes) -${LSDIFF} mixed-git.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include mixed-git.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 # Expected output explanation: @@ -49,7 +49,7 @@ a/regular-file.txt EOF # Test --git-prefixes=keep (explicit) -${LSDIFF} --git-prefixes=keep mixed-git.patch 2>errors2 >result2 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=keep mixed-git.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -60,7 +60,7 @@ a/regular-file.txt EOF # Test --git-prefixes=strip -${LSDIFF} --git-prefixes=strip mixed-git.patch 2>errors3 >result3 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip mixed-git.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 # Expected output explanation: @@ -76,7 +76,7 @@ regular-file.txt EOF # Test with filterdiff --git-prefixes=strip -${FILTERDIFF} --git-prefixes=strip -i "*.txt" mixed-git.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*.txt" mixed-git.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -90,7 +90,7 @@ index abcdefg..1234567 100644 EOF # Test with grepdiff --git-prefixes=strip -${GREPDIFF} --git-prefixes=strip --output-matching=file "content" mixed-git.patch 2>errors5 >result5 || exit 1 +${GREPDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip --output-matching=file "content" mixed-git.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 cat << EOF | cmp - result5 || exit 1 @@ -104,7 +104,7 @@ index abcdefg..1234567 100644 EOF # Test invalid argument -${LSDIFF} --git-prefixes=invalid mixed-git.patch 2>errors6 >result6 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=invalid mixed-git.patch 2>errors6 >result6 [ $? -eq 1 ] || exit 1 grep -q "invalid argument to --git-prefixes" errors6 || exit 1 diff --git a/tests/git-prefixes-with-strip/run-test b/tests/git-prefixes-with-strip/run-test index 0e7d4e77..121836a3 100755 --- a/tests/git-prefixes-with-strip/run-test +++ b/tests/git-prefixes-with-strip/run-test @@ -27,7 +27,7 @@ EOF # Test 1: --git-prefixes=keep (default) with -p and --strip # With keep: a/level1/level2/file1.txt -> -p1 -> level1/level2/file1.txt for matching # Then --strip=2 affects output: removes first 2 components from diff headers -${FILTERDIFF} --git-prefixes=keep -p1 --strip=2 -i "level1/level2/file1.txt" git-test.patch 2>errors1 >result1 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=keep -p1 --strip=2 -i "level1/level2/file1.txt" git-test.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 cat << EOF | cmp - result1 || exit 1 @@ -43,7 +43,7 @@ EOF # Test 2: --git-prefixes=strip with -p and --strip # With strip: a/level1/level2/file1.txt -> strip a/ -> level1/level2/file1.txt -> -p1 -> level2/file1.txt for matching # Then --strip=2 affects output -${FILTERDIFF} --git-prefixes=strip -p1 --strip=2 -i "level2/file1.txt" git-test.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -p1 --strip=2 -i "level2/file1.txt" git-test.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << EOF | cmp - result2 || exit 1 @@ -59,7 +59,7 @@ EOF # Test 3: --git-prefixes=strip with -p0 and --strip=1 # With strip: a/level1/level2/file1.txt -> strip a/ -> level1/level2/file1.txt -> -p0 -> level1/level2/file1.txt for matching # Then --strip=1 affects output -${FILTERDIFF} --git-prefixes=strip -p0 --strip=1 -i "level1/level2/file1.txt" git-test.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -p0 --strip=1 -i "level1/level2/file1.txt" git-test.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 @@ -74,7 +74,7 @@ EOF # Test 4: Verify exclusion works correctly with --git-prefixes=strip # Exclude "path/file2.c" after stripping a/ and applying -p1 -${FILTERDIFF} --git-prefixes=strip -p1 --strip=1 -x "path/file2.c" git-test.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -p1 --strip=1 -x "path/file2.c" git-test.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 diff --git a/tests/git-pure-rename/run-test b/tests/git-pure-rename/run-test index d411f906..93a0d33b 100755 --- a/tests/git-pure-rename/run-test +++ b/tests/git-pure-rename/run-test @@ -51,7 +51,7 @@ rename to src/new.c EOF echo "=== Test 1: lsdiff with pure rename ===" -${LSDIFF} -s git-pure-rename.patch 2>errors1 >result1 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-pure-rename.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 # For pure renames, both files exist so status should be '!' @@ -61,7 +61,7 @@ cat << EOF | cmp - result1 || exit 1 EOF echo "=== Test 2: filterdiff include pure rename ===" -${FILTERDIFF} -i "a/old*" git-pure-rename.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "a/old*" git-pure-rename.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << 'EOF' | cmp - result2 || exit 1 @@ -72,21 +72,21 @@ rename to new-name.txt EOF echo "=== Test 3: filterdiff include by new name (should not match) ===" -${FILTERDIFF} -i "new*" git-pure-rename.patch 2>errors3 >result3 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "new*" git-pure-rename.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 # Should be empty because best_name() chooses a/old-name.txt, which doesn't match "new*" [ -s result3 ] && exit 1 echo "=== Test 4: filterdiff exclude pure rename ===" -${FILTERDIFF} -x "*name*" git-pure-rename.patch 2>errors4 >result4 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -x "*name*" git-pure-rename.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 # Should be empty [ -s result4 ] && exit 1 echo "=== Test 5: lsdiff with rename that has changes ===" -${LSDIFF} -s git-rename-with-changes.patch 2>errors5 >result5 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-rename-with-changes.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 cat << EOF | cmp - result5 || exit 1 @@ -94,7 +94,7 @@ cat << EOF | cmp - result5 || exit 1 EOF echo "=== Test 6: lsdiff with multiple renames ===" -${LSDIFF} -s git-multiple-renames.patch 2>errors6 >result6 || exit 1 +${LSDIFF} --git-extended-diffs=include -s git-multiple-renames.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 @@ -103,7 +103,7 @@ cat << EOF | cmp - result6 || exit 1 EOF echo "=== Test 7: filterdiff with pattern matching one of multiple renames ===" -${FILTERDIFF} -i "a/file1*" git-multiple-renames.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "a/file1*" git-multiple-renames.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << 'EOF' | cmp - result7 || exit 1 @@ -114,7 +114,7 @@ rename to renamed1.txt EOF echo "=== Test 8: filterdiff with subdirectory rename ===" -${FILTERDIFF} -i "a/src/*" git-rename-subdir.patch 2>errors8 >result8 || exit 1 +${FILTERDIFF} --git-extended-diffs=include -i "a/src/*" git-rename-subdir.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 cat << 'EOF' | cmp - result8 || exit 1 @@ -125,7 +125,7 @@ rename to src/new.c EOF echo "=== Test 9: Test git-prefixes=strip with renames ===" -${LSDIFF} --git-prefixes=strip -s git-pure-rename.patch 2>errors9 >result9 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip -s git-pure-rename.patch 2>errors9 >result9 || exit 1 [ -s errors9 ] && exit 1 cat << EOF | cmp - result9 || exit 1 @@ -133,7 +133,7 @@ cat << EOF | cmp - result9 || exit 1 EOF echo "=== Test 10: Test git-prefixes=strip with filterdiff ===" -${FILTERDIFF} --git-prefixes=strip -i "old*" git-pure-rename.patch 2>errors10 >result10 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "old*" git-pure-rename.patch 2>errors10 >result10 || exit 1 [ -s errors10 ] && exit 1 cat << 'EOF' | cmp - result10 || exit 1 diff --git a/tests/git-rename-issue22/run-test b/tests/git-rename-issue22/run-test index 4ca7b1e4..7ed80e6c 100755 --- a/tests/git-rename-issue22/run-test +++ b/tests/git-rename-issue22/run-test @@ -13,7 +13,7 @@ rename to tests/wpt/web-platform-tests/2dcontext/transformations/2d.transformati EOF # Test that filterdiff includes the rename when it matches the filter -${FILTERDIFF} --git-prefixes=strip -i "*wpt*" git-rename.patch 2>errors >result || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i "*wpt*" git-rename.patch 2>errors >result || exit 1 [ -s errors ] && exit 1 # The result should contain the complete git diff block @@ -25,14 +25,14 @@ rename to tests/wpt/web-platform-tests/2dcontext/transformations/2d.transformati EOF # Test that filterdiff excludes the rename when it doesn't match the filter -${FILTERDIFF} --git-prefixes=strip -i something-else git-rename.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i something-else git-rename.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 # The result should be empty [ -s result2 ] && exit 1 # Test lsdiff works with renames -${LSDIFF} --git-prefixes=strip git-rename.patch 2>errors3 >result3 || exit 1 +${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip git-rename.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 cat << EOF | cmp - result3 || exit 1 diff --git a/tests/lsdiff-binary-numbering/run-test b/tests/lsdiff-binary-numbering/run-test index 30578878..930cc514 100755 --- a/tests/lsdiff-binary-numbering/run-test +++ b/tests/lsdiff-binary-numbering/run-test @@ -13,7 +13,8 @@ new file mode 100644 Binary files /dev/null and b/file2.bin differ EOF -${LSDIFF} -N diff 2>errors >output || exit 1 +# Note: using --git-extended-diffs=include to test binary file numbering +${LSDIFF} --git-extended-diffs=include -N diff 2>errors >output || exit 1 [ -s errors ] && exit 1 cat << 'EOF' | cmp - output || exit 1