From 365ec0dd8a54a6ada6cd0c5d75f9704cfe507c23 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sat, 13 Sep 2025 09:02:09 +0100 Subject: [PATCH 1/2] Better consistency for git diff rename filenames Assisted-by: Cursor --- doc/patchutils.xml | 38 +++++++++++++++++------------- src/diff.c | 19 +++++++++++++-- tests/git-complex-mixed/run-test | 8 +++---- tests/git-copy-operations/run-test | 6 ++--- tests/git-diff-edge-cases/run-test | 4 ++-- tests/git-prefixes-option/run-test | 8 +++---- tests/git-pure-rename/run-test | 28 +++++++++++++++------- 7 files changed, 71 insertions(+), 40 deletions(-) diff --git a/doc/patchutils.xml b/doc/patchutils.xml index 656f2554..7ea319a4 100644 --- a/doc/patchutils.xml +++ b/doc/patchutils.xml @@ -875,10 +875,10 @@ ). With keep (default), preserves existing behavior. Applies to both Git-specific diffs (binary files, renames, mode changes) and traditional diffs when part of a Git patch. - Note: Git rename operations use rename from/to headers - that contain literal filenames without a/ or - b/ prefixes, so this option does not affect renamed - filenames. The default will change to strip in version 0.5.0. + Note: With keep, copy and rename operations are treated as + if they had a/ and b/ prefixes for consistency + with other Git operations. The default will change to strip + in version 0.5.0. @@ -1066,7 +1066,11 @@ patch.file]]> file renames, and permission mode changes. For example, to extract only the renames from a git diff: - + @@ -1395,10 +1399,10 @@ patch.file]]> ). With keep (default), preserves existing behavior. Applies to both Git-specific diffs (binary files, renames, mode changes) and traditional diffs when part of a Git patch. - Note: Git rename operations use rename from/to headers - that contain literal filenames without a/ or - b/ prefixes, so this option does not affect renamed - filenames. The default will change to strip in version 0.5.0. + Note: With keep, copy and rename operations are treated as + if they had a/ and b/ prefixes for consistency + with other Git operations. The default will change to strip + in version 0.5.0. @@ -1802,10 +1806,10 @@ will pipe patch of file #2 to vim - -R ). With keep (default), preserves existing behavior. Applies to both Git-specific diffs (binary files, renames, mode changes) and traditional diffs when part of a Git patch. - Note: Git rename operations use rename from/to headers - that contain literal filenames without a/ or - b/ prefixes, so this option does not affect renamed - filenames. The default will change to strip in version 0.5.0. + Note: With keep, copy and rename operations are treated as + if they had a/ and b/ prefixes for consistency + with other Git operations. The default will change to strip + in version 0.5.0. @@ -2421,10 +2425,10 @@ will pipe patch of file #2 to vim - -R ). With keep (default), preserves existing behavior. Applies to both Git-specific diffs (binary files, renames, mode changes) and traditional diffs when part of a Git patch. - Note: Git rename operations use rename from/to headers - that contain literal filenames without a/ or - b/ prefixes, so this option does not affect renamed - filenames. The default will change to strip in version 0.5.0. + Note: With keep, copy and rename operations are treated as + if they had a/ and b/ prefixes for consistency + with other Git operations. The default will change to strip + in version 0.5.0. diff --git a/src/diff.c b/src/diff.c index c0bcea84..aaaf9a1a 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1234,8 +1234,23 @@ extract_git_filenames (char **headers, unsigned int num_headers, if (rename_from && rename_to) { /* Use rename headers for filenames */ - *old_name = xstrndup (rename_from, strcspn (rename_from, "\n\r")); - *new_name = xstrndup (rename_to, strcspn (rename_to, "\n\r")); + char *raw_old_name = xstrndup (rename_from, strcspn (rename_from, "\n\r")); + char *raw_new_name = xstrndup (rename_to, strcspn (rename_to, "\n\r")); + + /* Apply prefix mode consistently with other git operations */ + if (prefix_mode == GIT_PREFIX_KEEP) { + /* Add a/ and b/ prefixes to match behavior of diff --git line parsing */ + *old_name = xmalloc (strlen(raw_old_name) + 3); + sprintf (*old_name, "a/%s", raw_old_name); + *new_name = xmalloc (strlen(raw_new_name) + 3); + sprintf (*new_name, "b/%s", raw_new_name); + free (raw_old_name); + free (raw_new_name); + } else { + /* GIT_PREFIX_STRIP: use raw filenames (current behavior) */ + *old_name = raw_old_name; + *new_name = raw_new_name; + } } else { /* Parse filenames from "diff --git a/path b/path" line */ char *p = git_line + 11; /* Skip "diff --git " */ diff --git a/tests/git-complex-mixed/run-test b/tests/git-complex-mixed/run-test index 3eec2e6c..e46619a5 100755 --- a/tests/git-complex-mixed/run-test +++ b/tests/git-complex-mixed/run-test @@ -73,7 +73,7 @@ b/new-file.txt a/deleted-file.old a/binary-data.bin a/script-mode.sh -new-name.txt +b/new-name.txt a/copied-file.c a/regular-change.h EOF @@ -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} -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} -i "*/*.bin" complex-git.patch 2>errors4 >result4 || exit 1 [ -s errors4 ] && exit 1 cat << EOF | cmp - result4 || exit 1 @@ -113,7 +113,7 @@ 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} -x "*/*.old" complex-git.patch 2>errors5 >result5 || exit 1 [ -s errors5 ] && exit 1 # Should not contain deleted-file.old diff --git a/tests/git-copy-operations/run-test b/tests/git-copy-operations/run-test index d12f761c..9305bfee 100755 --- a/tests/git-copy-operations/run-test +++ b/tests/git-copy-operations/run-test @@ -119,10 +119,10 @@ ${LSDIFF} copy-binary.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 -data.bin +a/data.bin EOF -${FILTERDIFF} -i "data.bin" copy-binary.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} -i "a/data.bin" copy-binary.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << EOF | cmp - result7 || exit 1 @@ -157,7 +157,7 @@ ${LSDIFF} copy-rename-mixed.patch 2>errors8 >result8 || exit 1 cat << EOF | cmp - result8 || exit 1 a/file1.txt -file2.txt +a/file2.txt EOF # Test 6: Copy with very low similarity diff --git a/tests/git-diff-edge-cases/run-test b/tests/git-diff-edge-cases/run-test index abceb6da..c6661032 100755 --- a/tests/git-diff-edge-cases/run-test +++ b/tests/git-diff-edge-cases/run-test @@ -194,12 +194,12 @@ ${LSDIFF} -s mixed-git-types.patch 2>errors11 >result11 || exit 1 cat << EOF | cmp - result11 || exit 1 - a/deleted.txt -! old.txt +! a/old.txt ! a/script.sh EOF echo "=== Test 12: filterdiff with pattern matching mixed types ===" -${FILTERDIFF} -i "*.txt" mixed-git-types.patch 2>errors12 >result12 || exit 1 +${FILTERDIFF} -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-prefixes-option/run-test b/tests/git-prefixes-option/run-test index 52b56b5d..c18f2a90 100755 --- a/tests/git-prefixes-option/run-test +++ b/tests/git-prefixes-option/run-test @@ -38,12 +38,12 @@ ${LSDIFF} mixed-git.patch 2>errors1 >result1 || exit 1 # Expected output explanation: # - a/binary-file: from "diff --git a/binary-file b/binary-file" (keeps a/ prefix) -# - new-name: from "rename to new-name" header (no prefix to keep - rename headers don't use a/b/ prefixes) +# - b/new-name: best_name() chooses b/new-name over a/renamed-file (shorter basename: "new-name" vs "renamed-file") # - a/mode-only.sh: from "diff --git a/mode-only.sh b/mode-only.sh" (keeps a/ prefix) # - a/regular-file.txt: from "diff --git a/regular-file.txt b/regular-file.txt" (keeps a/ prefix) cat << EOF | cmp - result1 || exit 1 a/binary-file -new-name +b/new-name a/mode-only.sh a/regular-file.txt EOF @@ -54,7 +54,7 @@ ${LSDIFF} --git-prefixes=keep mixed-git.patch 2>errors2 >result2 || exit 1 cat << EOF | cmp - result2 || exit 1 a/binary-file -new-name +b/new-name a/mode-only.sh a/regular-file.txt EOF @@ -65,7 +65,7 @@ ${LSDIFF} --git-prefixes=strip mixed-git.patch 2>errors3 >result3 || exit 1 # Expected output explanation: # - binary-file: from "diff --git a/binary-file b/binary-file" (strips a/ prefix) -# - new-name: from "rename to new-name" header (no prefix to strip - same as keep mode) +# - new-name: best_name() chooses "new-name" over "renamed-file" (shorter basename) # - mode-only.sh: from "diff --git a/mode-only.sh b/mode-only.sh" (strips a/ prefix) # - regular-file.txt: from "diff --git a/regular-file.txt b/regular-file.txt" (strips a/ prefix) cat << EOF | cmp - result3 || exit 1 diff --git a/tests/git-pure-rename/run-test b/tests/git-pure-rename/run-test index 4cc5808b..d411f906 100755 --- a/tests/git-pure-rename/run-test +++ b/tests/git-pure-rename/run-test @@ -55,12 +55,13 @@ ${LSDIFF} -s git-pure-rename.patch 2>errors1 >result1 || exit 1 [ -s errors1 ] && exit 1 # For pure renames, both files exist so status should be '!' +# With --git-prefixes=keep (default), rename operations now use a/ prefix cat << EOF | cmp - result1 || exit 1 -! old-name.txt +! a/old-name.txt EOF echo "=== Test 2: filterdiff include pure rename ===" -${FILTERDIFF} -i "old*" git-pure-rename.patch 2>errors2 >result2 || exit 1 +${FILTERDIFF} -i "a/old*" git-pure-rename.patch 2>errors2 >result2 || exit 1 [ -s errors2 ] && exit 1 cat << 'EOF' | cmp - result2 || exit 1 @@ -74,7 +75,7 @@ echo "=== Test 3: filterdiff include by new name (should not match) ===" ${FILTERDIFF} -i "new*" git-pure-rename.patch 2>errors3 >result3 || exit 1 [ -s errors3 ] && exit 1 -# Should be empty because best_name() chooses the old name for renames +# 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 ===" @@ -97,12 +98,12 @@ ${LSDIFF} -s git-multiple-renames.patch 2>errors6 >result6 || exit 1 [ -s errors6 ] && exit 1 cat << EOF | cmp - result6 || exit 1 -! file1.txt -! file2.txt +! a/file1.txt +! a/file2.txt EOF echo "=== Test 7: filterdiff with pattern matching one of multiple renames ===" -${FILTERDIFF} -i "file1*" git-multiple-renames.patch 2>errors7 >result7 || exit 1 +${FILTERDIFF} -i "a/file1*" git-multiple-renames.patch 2>errors7 >result7 || exit 1 [ -s errors7 ] && exit 1 cat << 'EOF' | cmp - result7 || exit 1 @@ -113,7 +114,7 @@ rename to renamed1.txt EOF echo "=== Test 8: filterdiff with subdirectory rename ===" -${FILTERDIFF} -i "src/*" git-rename-subdir.patch 2>errors8 >result8 || exit 1 +${FILTERDIFF} -i "a/src/*" git-rename-subdir.patch 2>errors8 >result8 || exit 1 [ -s errors8 ] && exit 1 cat << 'EOF' | cmp - result8 || exit 1 @@ -123,7 +124,7 @@ rename from src/old.c rename to src/new.c EOF -echo "=== Test 9: Test git-prefixes with renames ===" +echo "=== Test 9: Test git-prefixes=strip with renames ===" ${LSDIFF} --git-prefixes=strip -s git-pure-rename.patch 2>errors9 >result9 || exit 1 [ -s errors9 ] && exit 1 @@ -131,6 +132,17 @@ cat << EOF | cmp - result9 || exit 1 ! old-name.txt 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 +[ -s errors10 ] && exit 1 + +cat << 'EOF' | cmp - result10 || exit 1 +diff --git a/old-name.txt b/new-name.txt +similarity index 100% +rename from old-name.txt +rename to new-name.txt +EOF + # Skip grepdiff test - pure renames have no content to grep echo "All pure rename tests passed!" From 94daf7cb863a96886ee9ecd43ce4b7be53059794 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sat, 13 Sep 2025 09:09:05 +0100 Subject: [PATCH 2/2] Reformatting change only Reformatted using xmllint --format --- doc/patchutils.xml | 4481 ++++++++++++++++++++------------------------ 1 file changed, 2061 insertions(+), 2420 deletions(-) diff --git a/doc/patchutils.xml b/doc/patchutils.xml index 7ea319a4..21629e61 100644 --- a/doc/patchutils.xml +++ b/doc/patchutils.xml @@ -1,712 +1,648 @@ - - + + + Patchutils - - Tim - Waugh - -
twaugh@redhat.com
-
- Package maintainer + Tim + Waugh + +
+ twaugh@redhat.com +
+
+ Package maintainer
- Man pages - patchutils - 23 June 2009 - - Michael K. - Johnson - -
johnsonm@redhat.com
-
- Original man page contributor -
+ patchutils + 23 June 2009 + + Michael K. + Johnson + +
+ johnsonm@redhat.com +
+
+ Original man page contributor +
- - interdiff - 1 + interdiff + 1 - - interdiff - show differences between two diff files + interdiff + show differences between two diff files - - - interdiff - - -p n - --strip-match=n - - - -U n - --unified=n - - - -d PAT - --drop-context=PAT - - - -q - --quiet - - - -z - --decompress - - - -b - --ignore-space-change - - - -B - --ignore-blank-lines - - - -i - --ignore-case - - - -w - --ignore-all-space - - --color=WHEN - - --interpolate - --combine - --flip - - --no-revert-omitted - diff1 - diff2 - - - - interdiff - - --help - --version - - + + interdiff + + -p n + --strip-match=n + + + -U n + --unified=n + + + -d PAT + --drop-context=PAT + + + -q + --quiet + + + -z + --decompress + + + -b + --ignore-space-change + + + -B + --ignore-blank-lines + + + -i + --ignore-case + + + -w + --ignore-all-space + + --color=WHEN + + --interpolate + --combine + --flip + + --no-revert-omitted + + diff1 + + + diff2 + + + + interdiff + + --help + --version + + - - Description - - interdiff creates a unified format + Description + interdiff creates a unified format diff that expresses the difference between two diffs. The diffs must both be relative to the same files. For best results, the diffs must have at least three lines of context. - - To reverse a patch, use /dev/null + To reverse a patch, use /dev/null for diff2. - - To reduce the amount of context in a patch, use: + To reduce the amount of context in a patch, use: - - Since interdiff doesn't have the + Since interdiff doesn't have the advantage of being able to look at the files that are to be modified, it has stricter requirements on the input format - than - patch - 1 - does. The output of GNU diff will be okay, + than patch1 does. The output of GNU diff will be okay, even with extensions, but if you intend to use a hand-edited patch it might be wise to clean up the offsets and counts - using - recountdiff - 1 - first. - - Note, however, that the two patches must both be + using recountdiff1 first. + Note, however, that the two patches must both be relative to the versions of the same original set of files. - - The diffs may be in context format. The output, + The diffs may be in context format. The output, however, will be in unified format. - - Options - - - - - - Ignored, for compatibility with older versions of + Options + + + + + + + Ignored, for compatibility with older versions of interdiff. This option will go away soon. - - - - - n, + + + + n, - - When comparing filenames, ignore the first + + When comparing filenames, ignore the first n pathname components from both patches. (This is similar to the - option to GNU - patch - 1 - .) If this option is not specified, + option to GNU patch1.) If this option is not specified, interdiff will automatically determine the optimal number of path components to strip by finding the smallest value where at least one file matches between the two patches. - - - - - , - - Quieter output. Don't emit rationale lines at the + + + + , + + Quieter output. Don't emit rationale lines at the beginning of each patch. - - - - - n, + + + + n, - - Attempt to display n + + Attempt to display n lines of context (requires at least n lines of context in both input files). (This is similar to the option to GNU - - diff - 1 - .) - - - - - PATTERN, + diff1.) + + + + PATTERN, - - Don't display any context on files that match the + + Don't display any context on files that match the shell wildcard PATTERN. This option can be given multiple times. - - Note that the interpretation of the shell wildcard + Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to fnmatch). This is so that */basename-type patterns can be given without limiting the number of pathname components. - - - - - , - - Consider upper- and lower-case to be the same. - - - - - , + + + + , + + Consider upper- and lower-case to be the same. + + + + , - - Ignore whitespace changes in patches. Also makes patch + + Ignore whitespace changes in patches. Also makes patch application ignore whitespace when reconstructing files. - - - - - , + + + + , - - Ignore changes in the amount of whitespace. - - - - - , + + Ignore changes in the amount of whitespace. + + + + , - - Ignore changes whose lines are all blank. - - - - - - - colorize the output; WHEN + + Ignore changes whose lines are all blank. + + + + + + + + colorize the output; WHEN can be 'never', 'always', or 'auto' (default: auto, use 'never' to disable) - - - - - , + + + + , - - Decompress files with extensions .gz and .bz2. - - - - - - - Run as interdiff. This is the + + Decompress files with extensions .gz and .bz2. + + + + + + + + Run as interdiff. This is the default. - - - - - - - Run as combinediff. See - - combinediff - 1 for more + + + + + + + + Run as combinediff. See + combinediff1 for more information about how the behaviour is altered in this mode. - - - - - - - (For interpolation mode only) When a file is + + + + + + + + (For interpolation mode only) When a file is changed by the first patch but not by the second, don't revert that change. - - - - - - - Display a short usage message. - - - - - - - Display the version number of interdiff. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of interdiff. + + + - - Examples - - Basic usage: + Examples + Basic usage: - Reversing a patch: + Reversing a patch: - - Reversing part of a patch (and ignoring the + Reversing part of a patch (and ignoring the rest): - - - Bugs - - There are currently no known bugs in interdiff; but + Bugs + There are currently no known bugs in interdiff; but there are some caveats. If you find a bug, please report it (along with a minimal test case) to Tim Waugh twaugh@redhat.com. - - There are some sets of patches in which there is just + There are some sets of patches in which there is just not enough information to produce a proper interdiff. In this case, the strategy employed is to revert the original patch and apply the new patch. This, unfortunately, means that interdiffs are not guaranteed to be reversible. - - - See also - - - combinediff - 1 - + See also + + + combinediff + 1 + +
- - patchutils - 23 Jan 2009 + patchutils + 23 Jan 2009 - - combinediff - 1 + combinediff + 1 - - combinediff - create a cumulative unified patch from two incremental + combinediff + create a cumulative unified patch from two incremental patches - - - combinediff - - -p n - --strip-match=n - - - -U n - --unified=n - - - -d PAT - --drop-context=PAT - - - -q - --quiet - - - -z - --decompress - - - -b - --ignore-space-change - - - -B - --ignore-blank-lines - - - -i - --ignore-case - - - -w - --ignore-all-space - - --color=WHEN - - --interpolate - --combine - - diff1 - diff2 - - - - combinediff - - --help - --version - - + + combinediff + + -p n + --strip-match=n + + + -U n + --unified=n + + + -d PAT + --drop-context=PAT + + + -q + --quiet + + + -z + --decompress + + + -b + --ignore-space-change + + + -B + --ignore-blank-lines + + + -i + --ignore-case + + + -w + --ignore-all-space + + --color=WHEN + + --interpolate + --combine + + + diff1 + + + diff2 + + + + combinediff + + --help + --version + + - - Description - - combinediff creates a unified diff that expresses the + Description + combinediff creates a unified diff that expresses the sum of two diffs. The diff files must be listed in the order that they are to be applied. For best results, the diffs must have at least three lines of context. - - Since combinediff doesn't have the + Since combinediff doesn't have the advantage of being able to look at the files that are to be modified, it has stricter requirements on the input format - than - patch - 1 - does. The output of GNU diff will be okay, + than patch1 does. The output of GNU diff will be okay, even with extensions, but if you intend to use a hand-edited patch it might be wise to clean up the offsets and counts - using - recountdiff - 1 - first. - - Note, however, that the two patches must be in strict + using recountdiff1 first. + Note, however, that the two patches must be in strict incremental order. In other words, the second patch must be relative to the state of the original set of files after the first patch was applied. - - The diffs may be in context format. The output, + The diffs may be in context format. The output, however, will be in unified format. - - Options - - - - n, + Options + + + n, - - When comparing filenames, ignore the first + + When comparing filenames, ignore the first n pathname components from both patches. (This is similar to the - option to GNU - patch - 1 - .) If this option is not specified, + option to GNU patch1.) If this option is not specified, combinediff will automatically determine the optimal number of path components to strip by finding the smallest value where at least one file matches between the two patches. - - - - - , - - Quieter output. Don't emit rationale lines at the + + + + , + + Quieter output. Don't emit rationale lines at the beginning of each patch. - - - - - n, + + + + n, - - Attempt to display n + + Attempt to display n lines of context (requires at least n lines of context in both input files). (This is similar to the option to GNU - - diff - 1 - .) - - - - - pattern, + diff1.) + + + + pattern, - - Don't display any context on files that match the + + Don't display any context on files that match the shell wildcard pattern. This option can be given multiple times. - - Note that the interpretation of the shell wildcard + Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to fnmatch). This is so that */basename-type patterns can be given without limiting the number of pathname components. - - - - - , - - Consider upper- and lower-case to be the same. - - - - - , + + + + , + + Consider upper- and lower-case to be the same. + + + + , - - Ignore whitespace changes in patches. Also makes patch + + Ignore whitespace changes in patches. Also makes patch application ignore whitespace when reconstructing files. - - - - - , + + + + , - - Ignore changes in the amount of whitespace. - - - - - , + + Ignore changes in the amount of whitespace. + + + + , - - Ignore changes whose lines are all blank. - - - - - - - colorize the output; WHEN + + Ignore changes whose lines are all blank. + + + + + + + + colorize the output; WHEN can be 'never', 'always', or 'auto' (default: auto, use 'never' to disable) - - - - - , + + + + , - - Decompress files with extensions .gz and .bz2. - - - - - - - Run as interdiff. See - - interdiff - 1 for more + + Decompress files with extensions .gz and .bz2. + + + + + + + + Run as interdiff. See + interdiff1 for more information about how the behaviour is altered in this mode. - - - - - - - Run as combinediff. This is the + + + + + + + + Run as combinediff. This is the default. - - - - - - - Display a short usage message. - - - - - - - Display the version number of combinediff. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of combinediff. + + + - - Bugs - - The option is a bit erratic: it can + Bugs + The option is a bit erratic: it can control the amount of context displayed for files that are modified in both patches, but not for files that only appear in one patch (which appear with the same amount of context in the output as in the input). - - See also - - - interdiff - 1 - + See also + + + interdiff + 1 + + - - patchutils - 23 Jan 2009 + patchutils + 23 Jan 2009 - - filterdiff - 1 + filterdiff + 1 - - filterdiff - extract or exclude diffs from a diff file + filterdiff + extract or exclude diffs from a diff file - - - filterdiff - - -i PATTERN - --include=PATTERN - - - -I FILE - --include-from-file=FILE - - - -p n - --strip-match=n - - --strip=n - --git-prefixes=strip|keep - --addprefix=PREFIX - --addoldprefix=PREFIX - --addnewprefix=PREFIX - - -x PATTERN - --exclude=PATTERN - - - -X FILE - --exclude-from-file=FILE - - - -v - --verbose - - --clean - --in-place - - -z - --decompress - - - -# RANGE - --hunks=RANGE - - --lines=RANGE - - -FRANGE - --files=RANGE - - --annotate - --format=FORMAT - --as-numbered-lines=WHEN - --remove-timestamps - file - - - - filterdiff - - --help - --version - --list - --grep ... - - + + filterdiff + + -i PATTERN + --include=PATTERN + + + -I FILE + --include-from-file=FILE + + + -p n + --strip-match=n + + --strip=n + --git-prefixes=strip|keep + --addprefix=PREFIX + --addoldprefix=PREFIX + --addnewprefix=PREFIX + + -x PATTERN + --exclude=PATTERN + + + -X FILE + --exclude-from-file=FILE + + + -v + --verbose + + --clean + --in-place + + -z + --decompress + + + -# RANGE + --hunks=RANGE + + --lines=RANGE + + -FRANGE + --files=RANGE + + --annotate + --format=FORMAT + --as-numbered-lines=WHEN + --remove-timestamps + + file + + + + filterdiff + + --help + --version + --list + --grep ... + + - - Description - - You can use filterdiff to obtain a patch that applies to + Description + You can use filterdiff to obtain a patch that applies to files matching the shell wildcard PATTERN from a larger collection of patches. For example, to see the patches in @@ -714,8 +650,7 @@ called lp.c: filterdiff -z -i '*/lp.c' patch-2.4.3.gz - - If neither nor + If neither nor options are given, is assumed. This way filterdiff can be used to clean up an existing diff file, removing redundant lines from the @@ -723,83 +658,72 @@ chunks (eg. in CVS diffs). To extract pure patch data, use a command like this: - filterdiff message-with-diff-in-the-body > patch - - Filterdiff supports unified, context, and Git format diffs. + filterdiff message-with-diff-in-the-body > patch + Filterdiff supports unified, context, and Git format diffs. Git format includes support for binary files, file renames, permission mode changes, and other Git-specific diff features. - - Note that the interpretation of the shell wildcard + Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to fnmatch). This is so that */basename-type patterns can be given without limiting the number of pathname components. - - You can use both unified and context format diffs with + You can use both unified and context format diffs with this program. - - - Options - - - - PATTERN, + Options + + + PATTERN, - - Include only files matching + + Include only files matching PATTERN. All other lines in the input are suppressed. - - - - - FILE, + + + + FILE, - - Include only files matching any pattern listed in + + Include only files matching any pattern listed in FILE, one pattern per line. All other lines in the input are suppressed. - - - - - PATTERN, + + + + PATTERN, - - Exclude files matching + + Exclude files matching PATTERN. All other lines in the input are displayed. - - - - - FILE, + + + + FILE, - - Exclude files matching any pattern listed in + + Exclude files matching any pattern listed in FILE, one pattern per line. All other lines in the input are displayed. - - - - - n, + + + + n, - - When matching, ignore the first + + When matching, ignore the first n components of the pathname. - - - - - RANGE, + + + + RANGE, =RANGE - - Only include hunks within the specified + + Only include hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, @@ -807,13 +731,12 @@ the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE - - Only include hunks that contain lines from the + + + + =RANGE + + Only include hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range is a comma-separated list of @@ -822,14 +745,13 @@ the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE, + + + + =RANGE, =RANGE - - Only include files indicated by the specified + + Only include files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or @@ -837,38 +759,34 @@ by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - - - - Annotate each hunk with the filename and hunk + + + + + + + + Annotate each hunk with the filename and hunk number. - - - - - =unified|context - - - Use specified output format. - - - - - =n - - Remove the first n + + + + =unified|context + + Use specified output format. + + + + =n + + Remove the first n components of pathnames in the output. - - - - - =strip|keep - - How to handle a/ and b/ + + + + =strip|keep + + How to handle a/ and b/ prefixes in Git diff filenames. With strip, removes the prefixes both for filename matching (when using and options) and for filename output (similar to @@ -879,190 +797,172 @@ if they had a/ and b/ prefixes for consistency with other Git operations. The default will change to strip in version 0.5.0. - - - - - =PREFIX - - Prefix pathnames in the output by + + + + =PREFIX + + Prefix pathnames in the output by PREFIX. This will override any individual settings specified with the or options. - - - - - =PREFIX - - Prefix pathnames for old or original files in the + + + + =PREFIX + + Prefix pathnames for old or original files in the output by PREFIX. - - - - - =PREFIX - - Prefix pathnames for updated or new files in the + + + + =PREFIX + + Prefix pathnames for updated or new files in the output by PREFIX. - - - - - =before|after|original-before|original-after - - Instead of a patch fragment, display the lines of + + + + =before|after|original-before|original-after + + Instead of a patch fragment, display the lines of the selected hunks with the line number of the file before (or after) the patch is applied, followed by a TAB character and a colon, at the beginning of each line. Each hunk except the first will have a line consisting of ... before it. - The before and after + The before and after options show line numbers adjusted for any skipped hunks. The original-before and original-after options show line numbers as they appear in the original diff, preserving the original line number context. This is useful for CI/CD systems that need to report errors on the exact line numbers from the original diff. - - - - - - - - Do not include file timestamps in the + + + + + + + + Do not include file timestamps in the output. - - - - - , - - Always show non-diff lines in the output. By + + + + , + + Always show non-diff lines in the output. By default, non-diff lines are only shown when excluding a filename pattern. - - - - - - - Always remove all non-diff lines from the + + + + + + + + Always remove all non-diff lines from the output. Even when excluding a filename pattern. - - - - - - - Write output to the original input files instead of + + + + + + + + Write output to the original input files instead of standard output. This allows filtering multiple patch files without manual redirection loops. - - - - - , - - Decompress files with extensions .gz and .bz2. - - - - - - - Display a short usage message. - - - - - - - Display the version number of filterdiff. - - - - - - - Behave like - lsdiff - 1 - instead. - - - - - - - Behave like - grepdiff - 1 - instead. - - - + + + + , + + Decompress files with extensions .gz and .bz2. + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of filterdiff. + + + + + + + + Behave like lsdiff1 instead. + + + + + + + + Behave like grepdiff1 instead. + + + - - Examples - - To see all patch hunks that affect the first five lines + Examples + To see all patch hunks that affect the first five lines of a C file: - - To see the first hunk of each file patch, use: + To see the first hunk of each file patch, use: - - To see patches modifying a ChangeLog file in a + To see patches modifying a ChangeLog file in a subdirectory, use: - - To see the complete patches for each patch that modifies + To see the complete patches for each patch that modifies line 1 of the original file, use: - - To see all but the first hunk of a particular patch, you + To see all but the first hunk of a particular patch, you might use: - - If you have a very specific list of hunks in a patch + If you have a very specific list of hunks in a patch that you want to see, list them: - - To see the lines of the files that would be patched as + To see the lines of the files that would be patched as they will appear after the patch is applied, use: - - You can see the same context before the patch is applied + You can see the same context before the patch is applied with: - - For CI/CD systems that need line numbers matching the original + For CI/CD systems that need line numbers matching the original diff context (useful for error reporting), use the original-* variants: - - Filterdiff can also be used to convert between unified + Filterdiff can also be used to convert between unified and context format diffs: - - Git format diffs are fully supported, including binary files, + Git format diffs are fully supported, including binary files, file renames, and permission mode changes. For example, to extract only the renames from a git diff: @@ -1072,230 +972,195 @@ filterdiff --git-prefixes=strip -i '*/newname' git-patch-with-renames.patch # With --git-prefixes=keep (default, matches with b/ prefix) filterdiff -i 'b/*/newname' git-patch-with-renames.patch]]> - - See also - - - lsdiff - 1 - , - grepdiff - 1 - , - patchview - 1 - + See also + lsdiff1, grepdiff1, patchview1 - - patchutils - 7 Dec 2001 - - - Amir - Karger - -
karger@post.harvard.edu
-
- Author of the original perl script and man page -
- - - John - Levon - -
moz@compsoc.man.ac.uk
-
- Author of the original perl script and man page -
-
+ patchutils + 7 Dec 2001 + + + Amir + Karger + +
+ karger@post.harvard.edu +
+
+ Author of the original perl script and man page +
+ + John + Levon + +
+ moz@compsoc.man.ac.uk +
+
+ Author of the original perl script and man page +
+
- - fixcvsdiff - 1 + fixcvsdiff + 1 - - fixcvsdiff - fix problematic diff files + fixcvsdiff + fix problematic diff files - - - fixcvsdiff - -p - -b - file - + + fixcvsdiff + -p + -b + + file + + - - Description - - fixcvsdiff modifies diff files created from the + Description + fixcvsdiff modifies diff files created from the cvs diff command, where files have been added or removed. CVS tends to create diff files that - - patch - 1 - mis-interprets. The diff file must retain the + patch1 mis-interprets. The diff file must retain the lines beginning with Index: in order for the correction to work. - - Options - - - - - - Keep a .bak backup file. - - - - - - - Print out the cvs add and + Options + + + + + + + Keep a .bak backup file. + + + + + + + + Print out the cvs add and cvs remove commands that must be made after applying the diff, but before running cvs commit. - - - + + + - - See also - - - diff - 1 - , - patch - 1 - , - cvs - 1 - + See also + diff1, patch1, cvs1
- - patchutils - 23 Jan 2009 + patchutils + 23 Jan 2009 - - lsdiff - 1 + lsdiff + 1 - - lsdiff - show which files are modified by a patch + lsdiff + show which files are modified by a patch - - - lsdiff - - -n - --line-number - - - -p n - --strip-match=n - - --strip=n - --git-prefixes=strip|keep - --addprefix=PREFIX - - -s - --status - - - -E - --empty-files-as-removed - - - -i PATTERN - --include=PATTERN - - - -x PATTERN - --exclude=PATTERN - - - -z - --decompress - - - -# RANGE - --hunks=RANGE - - --lines=RANGE - - -FRANGE - --files=RANGE - - - -H - --with-filename - - - -h - --no-filename - - - -v - --verbose - - file - - - - lsdiff - - --help - --version - --filter ... - --grep ... - - + + lsdiff + + -n + --line-number + + + -p n + --strip-match=n + + --strip=n + --git-prefixes=strip|keep + --addprefix=PREFIX + + -s + --status + + + -E + --empty-files-as-removed + + + -i PATTERN + --include=PATTERN + + + -x PATTERN + --exclude=PATTERN + + + -z + --decompress + + + -# RANGE + --hunks=RANGE + + --lines=RANGE + + -FRANGE + --files=RANGE + + + -H + --with-filename + + + -h + --no-filename + + + -v + --verbose + + + file + + + + lsdiff + + --help + --version + --filter ... + --grep ... + + - - Description - - List the files modified by a patch. - - You can use unified, context, and Git format diffs with + Description + List the files modified by a patch. + You can use unified, context, and Git format diffs with this program. Git format includes support for binary files, file renames, permission mode changes, and other Git-specific diff features. - - - Options - - - - , - - Display the line number that each patch begins at. + Options + + + , + + Display the line number that each patch begins at. If verbose output is requested (using ), each hunk of each patch is listed as well. - - For each file that is modified, a line is + For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab character, followed by the name of the file that is @@ -1306,30 +1171,27 @@ filterdiff -i 'b/*/newname' git-patch-with-renames.patch]]> another Tab character, the string Hunk #, and the hunk number (starting at 1). - - If the is given twice in + If the is given twice in conjunction with (i.e. ), the format is slightly different: hunk-level descriptive text is shown after each hunk number, and the option is enabled. - - - - - , - - File numbers are listed, beginning at 1, before + + + + , + + File numbers are listed, beginning at 1, before each filename. - - - - - RANGE, + + + + RANGE, =RANGE - - Only list hunks within the specified + + Only list hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, @@ -1337,13 +1199,12 @@ filterdiff -i 'b/*/newname' git-patch-with-renames.patch]]> the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE - - Only list hunks that contain lines from the + + + + =RANGE + + Only list hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range is a comma-separated list of @@ -1352,14 +1213,13 @@ filterdiff -i 'b/*/newname' git-patch-with-renames.patch]]> the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE, + + + + =RANGE, =RANGE - - Only list files indicated by the specified + + Only list files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or @@ -1367,32 +1227,29 @@ filterdiff -i 'b/*/newname' git-patch-with-renames.patch]]> modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - n, + + + + n, - - When matching, ignore the first + + When matching, ignore the first n components of the pathname. - - - - - =n - - Remove the first n + + + + =n + + Remove the first n components of the pathname before displaying it. - - - - - =strip|keep - - How to handle a/ and b/ + + + + =strip|keep + + How to handle a/ and b/ prefixes in Git diff filenames. With strip, removes the prefixes both for filename matching (when using and options) and for filename output (similar to @@ -1403,263 +1260,231 @@ filterdiff -i 'b/*/newname' git-patch-with-renames.patch]]> if they had a/ and b/ prefixes for consistency with other Git operations. The default will change to strip in version 0.5.0. - - - - - =PREFIX - - Prefix the pathname with + + + + =PREFIX + + Prefix the pathname with PREFIX before displaying it. - - - - - , - - Show file additions, modifications and removals. + + + + , + + Show file additions, modifications and removals. A file addition is indicated by a +, a removal by a -, and a modification by a !. - - - - - , + + + + , - - Treat empty files as absent for the purpose of + + Treat empty files as absent for the purpose of displaying file additions, modifications and removals. - - - - - PATTERN, + + + + PATTERN, - - Include only files matching + + Include only files matching PATTERN. - - - - - PATTERN, + + + + PATTERN, - - Exclude files matching + + Exclude files matching PATTERN. - - - - - , + + + + , - - Decompress files with extensions .gz and .bz2. + + Decompress files with extensions .gz and .bz2. - - - - - , - - Print the name of the patch file containing each + + + + , + + Print the name of the patch file containing each patch. - - - - - , - - Suppress the name of the patch file containing each + + + + , + + Suppress the name of the patch file containing each patch. - - - - - , - - Verbose output. - - - - - - - Display a short usage message. - - - - - - - Display the version number of lsdiff. - - - - - - - Behave like - filterdiff - 1 - instead. - - - - - - - Behave like - grepdiff - 1 - instead. - - - + + + + , + + Verbose output. + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of lsdiff. + + + + + + + + Behave like filterdiff1 instead. + + + + + + + + Behave like grepdiff1 instead. + + + - - See also - - - filterdiff - 1 - , - grepdiff - 1 - , - patchview - 1 - + See also + filterdiff1, grepdiff1, patchview1 - - Examples - - To sort the order of touched files in a patch, you can + Examples + To sort the order of touched files in a patch, you can use: - - To show only added files in a patch: + To show only added files in a patch: - - To show the headers of all file hunks: + To show the headers of all file hunks: - - patchutils - 02 Jul 2020 + patchutils + 02 Jul 2020 - - patchview - 1 + patchview + 1 - - patchview - Without options, show numbered files modified by the patch. With options, behave as filterdiff. + patchview + Without options, show numbered files modified by the patch. With options, behave as filterdiff. - - - patchview - - -n - --line-number - - - -p n - --strip-match=n - - --strip=n - --git-prefixes=strip|keep - --addprefix=PREFIX - - -s - --status - - - -E - --empty-files-as-removed - - - -i PATTERN - --include=PATTERN - - - -x PATTERN - --exclude=PATTERN - - - -z - --decompress - - - -# RANGE - --hunks=RANGE - - --lines=RANGE - - -FRANGE - --files=RANGE - - - -H - --with-filename - - - -h - --no-filename - - - -v - --verbose - - file - - - - patchview - - --help - --version - --filter ... - --grep ... - - + + patchview + + -n + --line-number + + + -p n + --strip-match=n + + --strip=n + --git-prefixes=strip|keep + --addprefix=PREFIX + + -s + --status + + + -E + --empty-files-as-removed + + + -i PATTERN + --include=PATTERN + + + -x PATTERN + --exclude=PATTERN + + + -z + --decompress + + + -# RANGE + --hunks=RANGE + + --lines=RANGE + + -FRANGE + --files=RANGE + + + -H + --with-filename + + + -h + --no-filename + + + -v + --verbose + + + file + + + + patchview + + --help + --version + --filter ... + --grep ... + + - - Description - - So what is patchview? It is a wrapper of filterdiff for use with numbered files. + Description + So what is patchview? It is a wrapper of filterdiff for use with numbered files. patchview (without args) is equivalent to: lsdiff --number - - patchview -F2- + patchview -F2- (or with any other args) is equivalent to: filterdiff -F2- (or whatever arguments are supplied) - + There are two scripts for working with git (gitdiff and gitdiffview) and two for svn (svndiff and svndiffview). svndiff @@ -1668,41 +1493,31 @@ There are two scripts for working with git (gitdiff and gitdiffview) and two for will give the list of files modified - - svndiff -F1 - gitdiff -F1 + svndiff -F1gitdiff -F1 will show the patch of file #1 - - svndiffview - gitdiffview + svndiffviewgitdiffview pipe all patches through filterdiff to vim - -R (in read-only mode, easy to quit), showing complete patch with color. - - svndiffview -F2 - gitdiffview -F2 + svndiffview -F2gitdiffview -F2 (or any other args) will pipe patch of file #2 to vim - -R - - - Options - - - - , - - Display the line number that each patch begins at. + Options + + + , + + Display the line number that each patch begins at. If verbose output is requested (using ), each hunk of each patch is listed as well. - - For each file that is modified, a line is + For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab character, followed by the name of the file that is @@ -1713,30 +1528,27 @@ will pipe patch of file #2 to vim - -R another Tab character, the string Hunk #, and the hunk number (starting at 1). - - If the is given twice in + If the is given twice in conjunction with (i.e. ), the format is slightly different: hunk-level descriptive text is shown after each hunk number, and the option is enabled. - - - - - , - - File numbers are listed, beginning at 1, before + + + + , + + File numbers are listed, beginning at 1, before each filename. - - - - - RANGE, + + + + RANGE, =RANGE - - Only list hunks within the specified + + Only list hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, @@ -1744,13 +1556,12 @@ will pipe patch of file #2 to vim - -R the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE - - Only list hunks that contain lines from the + + + + =RANGE + + Only list hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range is a comma-separated list of @@ -1759,14 +1570,13 @@ will pipe patch of file #2 to vim - -R the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE, + + + + =RANGE, =RANGE - - Only list files indicated by the specified + + Only list files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or @@ -1774,32 +1584,29 @@ will pipe patch of file #2 to vim - -R modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - n, + + + + n, - - When matching, ignore the first + + When matching, ignore the first n components of the pathname. - - - - - =n - - Remove the first n + + + + =n + + Remove the first n components of the pathname before displaying it. - - - - - =strip|keep - - How to handle a/ and b/ + + + + =strip|keep + + How to handle a/ and b/ prefixes in Git diff filenames. With strip, removes the prefixes both for filename matching (when using and options) and for filename output (similar to @@ -1810,615 +1617,531 @@ will pipe patch of file #2 to vim - -R if they had a/ and b/ prefixes for consistency with other Git operations. The default will change to strip in version 0.5.0. - - - - - =PREFIX - - Prefix the pathname with + + + + =PREFIX + + Prefix the pathname with PREFIX before displaying it. - - - - - , - - Show file additions, modifications and removals. + + + + , + + Show file additions, modifications and removals. A file addition is indicated by a +, a removal by a -, and a modification by a !. - - - - - , + + + + , - - Treat empty files as absent for the purpose of + + Treat empty files as absent for the purpose of displaying file additions, modifications and removals. - - - - - PATTERN, + + + + PATTERN, - - Include only files matching + + Include only files matching PATTERN. - - - - - PATTERN, + + + + PATTERN, - - Exclude files matching + + Exclude files matching PATTERN. - - - - - , + + + + , - - Decompress files with extensions .gz and .bz2. + + Decompress files with extensions .gz and .bz2. - - - - - , - - Print the name of the patch file containing each + + + + , + + Print the name of the patch file containing each patch. - - - - - , - - Suppress the name of the patch file containing each + + + + , + + Suppress the name of the patch file containing each patch. - - - - - , - - Verbose output. - - - - - - - Display a short usage message. - - - - - - - Display the version number of patchview. - - - - - - - Behave like - filterdiff - 1 - instead. - - - - - - - Behave like - grepdiff - 1 - instead. - - - + + + + , + + Verbose output. + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of patchview. + + + + + + + + Behave like filterdiff1 instead. + + + + + + + + Behave like grepdiff1 instead. + + + - - See also - - - lsdiff - 1 - , - filterdiff - 1 - , - grepdiff - 1 - + See also + lsdiff1,filterdiff1, grepdiff1 - - Examples - We can make the following one-line script with the name difftotrunk.sh, to view the differences of two directories or svn repos (trunk and .) + Examples + We can make the following one-line script with the name difftotrunk.sh, to view the differences of two directories or svn repos (trunk and .) - - ./difftotrunk.sh , will show all different files and his number. - ./difftotrunk.sh -F3,4 , will show the differences of files #3 and #4 only. - ./difftotrunk.sh -F3 -#1 , will show only hunk #1 of file #3. - ./difftotrunk.sh -F3 -#x1 , will show the differences of files #3 without hunk #1 (x means that exclude). - - - + + ./difftotrunk.sh , will show all different files and his number. + ./difftotrunk.sh -F3,4 , will show the differences of files #3 and #4 only. + ./difftotrunk.sh -F3 -#1 , will show only hunk #1 of file #3. + ./difftotrunk.sh -F3 -#x1 , will show the differences of files #3 without hunk #1 (x means that exclude). + +
- patchutils - 4 Nov 2014 + patchutils + 4 Nov 2014 - - splitdiff - 1 + splitdiff + 1 - - splitdiff - separate out incremental patches + splitdiff + separate out incremental patches - - - splitdiff - -a - -d - -D dir - -p n - -E - file - - - - splitdiff - - --help - --version - - + + splitdiff + -a + -d + -D dir + -p n + -E + + file + + + + splitdiff + + --help + --version + + - - Description - - If you have a patch file composed of several incremental + Description + If you have a patch file composed of several incremental patches, you can use splitdiff to separate them out. You may want to do this in preparation for re-combining them - with - combinediff - 1. - - The effect of running splitdiff is to separate its input + with combinediff1. + The effect of running splitdiff is to separate its input into a set of output files, with no output file patching the same file more than once. - - Options - - - - - - Split out every single file-level patch. - - - - - - - Create file names such as + Options + + + + + + + Split out every single file-level patch. + + + + + + + + Create file names such as a_b.c.patch for a patch that modifies a/b.c. - - - - - - dir - - Write output files into subdirectory + + + + + + dir + + + Write output files into subdirectory dir. Implies . - - - - - n - - Strip the first n + + + + + + n + + + Strip the first n components of the pathname to aid comparisons. - - - - - - - Don't use .patch filename extension when writing + + + + + + + + Don't use .patch filename extension when writing output files. - - - - - - - Display a short usage message. - - - - - - - Display the version number of splitdiff. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of splitdiff. + + + - - See also - - - combinediff - 1 - , - lsdiff - 1 - + See also + combinediff1, lsdiff1 - - patchutils - 13 May 2002 + patchutils + 13 May 2002 - - rediff - 1 + rediff + 1 - - rediff - editdiff - fix offsets and counts of a hand-edited diff + rediff + editdiff + fix offsets and counts of a hand-edited diff - - - rediff - --in-place - ORIGINAL - EDITED - - - - rediff - --in-place - EDITED - - - - rediff - - --help - --version - - - - - editdiff - FILE - - - - editdiff - - --help - --version - - + + rediff + --in-place + + ORIGINAL + + + EDITED + + + + rediff + --in-place + + EDITED + + + + rediff + + --help + --version + + + + editdiff + + FILE + + + + editdiff + + --help + --version + + - - Description - - You can use rediff to correct a hand-edited unified + Description + You can use rediff to correct a hand-edited unified diff. Take a copy of the diff you want to edit, and edit it without changing any offsets or counts (the lines that begin @@). Then run rediff, telling it the name of the original diff file and the name of the one you have edited, and it will output the edited diff file but with corrected offsets and counts. - - A small script, editdiff, is provided for editing a diff + A small script, editdiff, is provided for editing a diff file in-place. - - The types of changes that are currently handled + The types of changes that are currently handled are: - - - Modifying the text of any file content line (of - course). - - - - Adding new line insertions or deletions. - - - - Adding, changing or removing context lines. Lines + Modifying the text of any file content line (of + course).Adding new line insertions or deletions.Adding, changing or removing context lines. Lines at the context horizon are dealt with by adjusting the - offset and/or count. - - - - Adding a single hunk (@@-prefixed section). - - - - Removing multiple hunk (@@-prefixed - sections). - - - - Alternatively, if only one argument is provided, it is + offset and/or count.Adding a single hunk (@@-prefixed section).Removing multiple hunk (@@-prefixed + sections). + Alternatively, if only one argument is provided, it is taken to be the edited file and the counts and offsets are adjusted as appropriate. Some assumptions are made when - used in this mode. See - recountdiff - 1 - for more information. + used in this mode. See recountdiff1 for more information. - - Options - - - - - - - Write output to the original edited file instead of + Options + + + + + + + Write output to the original edited file instead of standard output. When used with two arguments, the result is written back to the EDITED file. - - - - - - - Display a short usage message. - - - - - - - Display the version number of rediff. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of rediff. + + + - - See also - - - interdiff - 1 - , - recountdiff - 1 - + See also + interdiff1, recountdiff1 - - patchutils - 10 Feb 2011 + patchutils + 10 Feb 2011 - - grepdiff - 1 + grepdiff + 1 - - grepdiff - show files modified by a diff containing a + grepdiff + show files modified by a diff containing a regex - - - grepdiff - - -n - --line-number - - - -N - --number-files - - - -p n - --strip-match=n - - --strip=n - --git-prefixes=strip|keep - --addprefix=PREFIX - --addoldprefix=PREFIX - --addnewprefix=PREFIX - - -s - --status - - - -i PATTERN - --include=PATTERN - - - -I FILE - --include-from-file=FILE - - - -x PATTERN - --exclude=PATTERN - - - -X FILE - --exclude-from-file=FILE - - - -# RANGE - --hunks=RANGE - - --lines=RANGE - - -FRANGE - --files=RANGE - - --annotate - --as-numbered-lines=WHEN - --format=FORMAT - --remove-timestamps - - -v - --verbose - - - -z - --decompress - - - -E - --extended-regexp - - - -H - --with-filename - - - -h - --no-filename - - --output-matching=WHAT - --only-match=WHAT - - REGEX - -f FILE - - file - - - - grepdiff - - --help - --version - --list - --filter ... - - + + grepdiff + + -n + --line-number + + + -N + --number-files + + + -p n + --strip-match=n + + --strip=n + --git-prefixes=strip|keep + --addprefix=PREFIX + --addoldprefix=PREFIX + --addnewprefix=PREFIX + + -s + --status + + + -i PATTERN + --include=PATTERN + + + -I FILE + --include-from-file=FILE + + + -x PATTERN + --exclude=PATTERN + + + -X FILE + --exclude-from-file=FILE + + + -# RANGE + --hunks=RANGE + + --lines=RANGE + + -FRANGE + --files=RANGE + + --annotate + --as-numbered-lines=WHEN + --format=FORMAT + --remove-timestamps + + -v + --verbose + + + -z + --decompress + + + -E + --extended-regexp + + + -H + --with-filename + + + -h + --no-filename + + --output-matching=WHAT + --only-match=WHAT + + + REGEX + + -f FILE + + + file + + + + grepdiff + + --help + --version + --list + --filter ... + + - - Description - - For each file modified by a patch, if the patch hunk + Description + For each file modified by a patch, if the patch hunk contains the REGEX then the file's name is printed. - - The regular expression is treated as POSIX Basic Regular + The regular expression is treated as POSIX Basic Regular Expression syntax, unless the option is given in which case POSIX Extended Regular Expression syntax is used. When compiled with PCRE2 support, PCRE regular expressions are used instead of POSIX regular expressions, and the option has no effect since PCRE already supports extended regular expression features by default. - - For example, to see the patches in + For example, to see the patches in my.patch which contain the regular expression pf_gfp_mask, use: - - You can use unified, context, and Git format diffs with + You can use unified, context, and Git format diffs with this program. Git format includes support for binary files, file renames, permission mode changes, and other Git-specific diff features. - - - Options - - - - , - - Display the line number that each patch begins at. + Options + + + , + + Display the line number that each patch begins at. If verbose output is requested, each matching hunk is listed as well. - - For a description of the output format see - - lsdiff - 1 - . - - - - - , - - File numbers are listed, beginning at 1, before + For a description of the output format see + lsdiff1. + + + + , + + File numbers are listed, beginning at 1, before each filename. - - - - - n, + + + + n, - - When matching, ignore the first + + When matching, ignore the first n components of the pathname. - - - - - =n - - Remove the first n + + + + =n + + Remove the first n components of the pathname before displaying it. - - - - - =strip|keep - - How to handle a/ and b/ + + + + =strip|keep + + How to handle a/ and b/ prefixes in Git diff filenames. With strip, removes the prefixes both for filename matching (when using and options) and for filename output (similar to @@ -2429,102 +2152,97 @@ will pipe patch of file #2 to vim - -R if they had a/ and b/ prefixes for consistency with other Git operations. The default will change to strip in version 0.5.0. - - - - - =PREFIX - - Prefix the pathname with + + + + =PREFIX + + Prefix the pathname with PREFIX before displaying it. This will override any individual settings specified with the or options. - - - - - =PREFIX - - Prefix pathnames for old or original files in the + + + + =PREFIX + + Prefix pathnames for old or original files in the output by PREFIX. - - - - - =PREFIX - - Prefix pathnames for updated or new files in the + + + + =PREFIX + + Prefix pathnames for updated or new files in the output by PREFIX. - - - - - - - Show file additions, modifications and removals. + + + + + + + + Show file additions, modifications and removals. A file addition is indicated by a +, a removal by a -, and a modification by a !. - - - - - PATTERN, + + + + PATTERN, - - Include only files matching + + Include only files matching PATTERN. - - - - - FILE, + + + + FILE, - - Include only files matching any pattern listed in + + Include only files matching any pattern listed in FILE, one pattern per line. All other lines in the input are suppressed. - - - - - PATTERN - - - Exclude files matching + + + + + + PATTERN + + + + Exclude files matching PATTERN. - - - - - FILE, + + + + FILE, - - Exclude files matching any pattern listed in + + Exclude files matching any pattern listed in FILE, one pattern per line. All other lines in the input are displayed. - - - - - RANGE, + + + + RANGE, =RANGE - - Only include hunks within the specified + + Only include hunks within the specified RANGE. Hunks are numbered from 1, and the range is a comma-separated list of numbers or first-last spans, optionally preceded by a modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE - - Only list hunks that contain lines from the + + + + =RANGE + + Only list hunks that contain lines from the original file that lie within the specified RANGE. Lines are numbered from 1, and the range is a comma-separated list of @@ -2533,14 +2251,13 @@ will pipe patch of file #2 to vim - -R the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - =RANGE, + + + + =RANGE, =RANGE - - Only list files indicated by the specified + + Only list files indicated by the specified RANGE. Files are numbered from 1 in the order they appear in the patch input, and the range is a comma-separated list of numbers or @@ -2548,797 +2265,721 @@ will pipe patch of file #2 to vim - -R modifier 'x' which inverts the entire range; either the first or the last in the span may be omitted to indicate no limit in that direction. - - - - - - - - Annotate each hunk with the filename and hunk + + + + + + + + Annotate each hunk with the filename and hunk number. - - - - - =before|after|original-before|original-after - - Instead of a patch fragment, display the lines of + + + + =before|after|original-before|original-after + + Instead of a patch fragment, display the lines of the selected hunks with the line number of the file before (or after) the patch is applied, followed by a TAB character and a colon, at the beginning of each line. Each hunk except the first will have a line consisting of ... before it. - The before and after + The before and after options show line numbers adjusted for any skipped hunks. The original-before and original-after options show line numbers as they appear in the original diff, preserving the original line number context. This is useful for CI/CD systems that need to report errors on the exact line numbers from the original diff. - - - - - =unified|context - - - Use specified output format. - - - - - - - - Do not include file timestamps in the + + + + =unified|context + + Use specified output format. + + + + + + + + Do not include file timestamps in the output. - - - - - , + + + + , - - Decompress files with extensions .gz and .bz2. - - - - - , + + Decompress files with extensions .gz and .bz2. + + + + , - - Use POSIX Extended Regular Expression + + Use POSIX Extended Regular Expression syntax. Note: when compiled with PCRE2 support, this option has no effect as PCRE regular expressions are used by default and already support extended regular expression features. - - - - - , - - Print the name of the patch file containing each + + + + , + + Print the name of the patch file containing each match. - - - - - , - - Suppress the name of the patch file containing each + + + + , + + Suppress the name of the patch file containing each match. - - - - - FILE, + + + + FILE, - - Read regular expressions from + + Read regular expressions from FILE, one per line. - - - - - =hunk|file - - Display the matching hunk-level or file-level + + + + =hunk|file + + Display the matching hunk-level or file-level diffs. - - - - - =rem|removals|add|additions|mod|modifications|all - - Limit regex matching to removals, additions, modifications or + + + + =rem|removals|add|additions|mod|modifications|all + + Limit regex matching to removals, additions, modifications or the whole hunk. - - - - - - - Display a short usage message. - - - - - - - Display the version number of grepdiff. - - - - - - - Behave like - filterdiff - 1 - instead. - - - - - - - Behave like - lsdiff - 1 - instead. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of grepdiff. + + + + + + + + Behave like filterdiff1 instead. + + + + + + + + Behave like lsdiff1 instead. + + + - - Examples - - Git format diffs are fully supported. For example, to find + Examples + Git format diffs are fully supported. For example, to find files in a git patch that contain changes to malloc calls: - - Note that grepdiff searches in the hunk content (the actual + Note that grepdiff searches in the hunk content (the actual code changes), not in Git metadata like rename headers. Files with only renames or mode changes (no content hunks) won't be found even if the pattern appears in the Git headers. - - See also - - - filterdiff - 1 - , - lsdiff - 1 - , - patchview - 1 - + See also + filterdiff1, lsdiff1, patchview1 - - patchutils - 5 July 2002 + patchutils + 5 July 2002 - - recountdiff - 1 + recountdiff + 1 - - recountdiff - recompute patch counts and offsets + recountdiff + recompute patch counts and offsets - - - recountdiff - file - - - - recountdiff - - --help - --version - - + + recountdiff + + file + + + + recountdiff + + --help + --version + + - - Description - - recountdiff recomputes the counts and + Description + recountdiff recomputes the counts and offsets in unified context diffs. It does this in two passes: first the counts are corrected by inspection of the actual patch lines, and then the offsets are adjusted according to the computed counts. - - The corrected diff is sent to standard output. + The corrected diff is sent to standard output. - - Options - - - - - - Display a short usage message. - - - - - - - Display the version number of recountdiff. - - - + Options + + + + + + + Display a short usage message. + + + + + + + + Display the version number of recountdiff. + + + - - Limitations - - There are some things that cannot be dealt with. If you + Limitations + There are some things that cannot be dealt with. If you have removed the first context line in a hunk, for example, there is no way for recountdiff to know - that. For more precise fixing up, use - rediff - 1 - , which uses the original and modified + that. For more precise fixing up, use rediff1, which uses the original and modified diffs. - - See also - - - rediff - 1 - + See also + + + rediff + 1 + + - - patchutils - 17 January 2003 + patchutils + 17 January 2003 - - unwrapdiff - 1 + unwrapdiff + 1 - - unwrapdiff - demangle word-wrapped patches + unwrapdiff + demangle word-wrapped patches - - - unwrapdiff - -v - file - - - - unwrapdiff - - --help - --version - - + + unwrapdiff + -v + + file + + + + unwrapdiff + + --help + --version + + - - Description - - unwrapdiff demangles patches that + Description + unwrapdiff demangles patches that have been word-wrapped, in an attempt to make them useful. - - The corrected diff is sent to standard output. Note + The corrected diff is sent to standard output. Note that you will probably need to use the option when applying the patch, in order to ignore any whitespace differences there may be. - - Options - - - - - - Verbose operation. A list of lines that are + Options + + + + + + + Verbose operation. A list of lines that are modified in a way that might be wrong is sent to stderr. - - - - - - - Display a short usage message. - - - - - - - Display the version number of unwrapdiff. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of unwrapdiff. + + + - - Limitations - - Some heuristics are used to decide whether use a space + Limitations + Some heuristics are used to decide whether use a space to recombine a wrapped line, or just join them together. Currently this is done by comparing with last three characters of a line with the first two characters of its continuation, and using a space if any of them are different. - - The patch needs to have been valid before being + The patch needs to have been valid before being word-wrapped. - - The last line of a hunk is nearly always ambiguous. If + The last line of a hunk is nearly always ambiguous. If the next line begins @@, Index: , diff  or ---  then it is taken to be complete; otherwise it is unwrapped using the next line. - - patchutils - 17 January 2003 + patchutils + 17 January 2003 - - dehtmldiff - 1 + dehtmldiff + 1 - - dehtmldiff - get usable diff from an HTML page + dehtmldiff + get usable diff from an HTML page - - - dehtmldiff - file - - - - dehtmldiff - - --help - --version - - + + dehtmldiff + + file + + + + dehtmldiff + + --help + --version + + - - Description - - dehtmldiff creates usable diff files + Description + dehtmldiff creates usable diff files from HTML pages. This is useful in the scenario where a patch has been posted to a mailing list viewable via a web page. - - The corrected diff is sent to standard output. Note + The corrected diff is sent to standard output. Note that you will probably need to use the option when applying the patch, in order to ignore any whitespace differences there may be. - - Options - - - - - - Display a short usage message. - - - - - - - Display the version number of dehtmldiff. - - - + Options + + + + + + + Display a short usage message. + + + + + + + + Display the version number of dehtmldiff. + + + - - Limitations - - The way this command works is fairly primitive; it boils + Limitations + The way this command works is fairly primitive; it boils down to some simple text replacements, followed by an unwrapdiff pass. As a result, all of the limitations that apply to unwrapdiff also apply to dehtmldiff. - - patchutils - 23 January 2009 + patchutils + 23 January 2009 - - flipdiff - 1 + flipdiff + 1 - - flipdiff - exchange the order of two incremental patches + flipdiff + exchange the order of two incremental patches - - - flipdiff - - -p n - --strip-match=n - - - -U n - --unified=n - - - -d PAT - --drop-context=PAT - - - -q - --quiet - - - -z - --decompress - - - -b - --ignore-space-change - - - -B - --ignore-blank-lines - - - -i - --ignore-case - - - -w - --ignore-all-space - - --color=WHEN - --in-place - diff1 - diff2 - - - - flipdiff - - --help - --version - - + + flipdiff + + -p n + --strip-match=n + + + -U n + --unified=n + + + -d PAT + --drop-context=PAT + + + -q + --quiet + + + -z + --decompress + + + -b + --ignore-space-change + + + -B + --ignore-blank-lines + + + -i + --ignore-case + + + -w + --ignore-all-space + + --color=WHEN + --in-place + + diff1 + + + diff2 + + + + flipdiff + + --help + --version + + - - Description - - flipdiff exchanges the order of two + Description + flipdiff exchanges the order of two patch files that apply one after the other. The patches must be clean: the context lines must match and there should be no mis-matched offsets. - - The swapped patches are sent to standard output, with a + The swapped patches are sent to standard output, with a marker line (=== 8< === cut here === 8< ===) between them, unless the option is passed. In that case, the output is written back to the original input files. - - Options - - - - n, + Options + + + n, - - When comparing filenames, ignore the first + + When comparing filenames, ignore the first n pathname components from both patches. (This is similar to the - option to GNU - patch - 1 - .) If this option is not specified, + option to GNU patch1.) If this option is not specified, flipdiff will automatically determine the optimal number of path components to strip by finding the smallest value where at least one file matches between the two patches. - - - - - , - - Quieter output. Don't emit rationale lines at the + + + + , + + Quieter output. Don't emit rationale lines at the beginning of each patch. - - - - - n, + + + + n, - - Attempt to display n + + Attempt to display n lines of context (requires at least n lines of context in both input files). (This is similar to the option to GNU - - diff - 1 - .) - - - - - pattern, + diff1.) + + + + pattern, - - Don't display any context on files that match the + + Don't display any context on files that match the shell wildcard pattern. This option can be given multiple times. - - Note that the interpretation of the shell wildcard + Note that the interpretation of the shell wildcard pattern does not count slash characters or periods as special (in other words, no flags are given to fnmatch). This is so that */basename-type patterns can be given without limiting the number of pathname components. - - - - - , - - Consider upper- and lower-case to be the same. - - - - - , + + + + , + + Consider upper- and lower-case to be the same. + + + + , - - Ignore whitespace changes in patches. Also makes patch + + Ignore whitespace changes in patches. Also makes patch application ignore whitespace when reconstructing files. - - - - - , + + + + , - - Ignore changes in the amount of whitespace. - - - - - , + + Ignore changes in the amount of whitespace. + + + + , - - Ignore changes whose lines are all blank. - - - - - - - colorize the output; WHEN + + Ignore changes whose lines are all blank. + + + + + + + + colorize the output; WHEN can be 'never', 'always', or 'auto' (default: auto, use 'never' to disable) - - - - - , + + + + , - - Decompress files with extensions .gz and .bz2. - - - - - - - Write output to the original input files. - - - - - - - Display a short usage message. - - - - - - - Display the version number of flipdiff. - - - + + Decompress files with extensions .gz and .bz2. + + + + + + + + Write output to the original input files. + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of flipdiff. + + + - - Limitations - - This is only been very lightly tested, and may not even + Limitations + This is only been very lightly tested, and may not even work. Using is not recommended at the moment. - - There are some cases in which it is not possible to + There are some cases in which it is not possible to meaningfully flip patches without understanding the semantics of the content. This program only uses complete lines that appear at some stage during the application of the two patches, and never composes a line from parts. - - Because of this, it is generally a good idea to read + Because of this, it is generally a good idea to read through the output to check that it makes sense. - - patchutils - 5 March 2003 - - - Mike - Harris - -
mharris@redhat.com
-
- Conceptual designer -
-
+ patchutils + 5 March 2003 + + + Mike + Harris + +
+ mharris@redhat.com +
+
+ Conceptual designer +
+
- - espdiff - 1 + espdiff + 1 - - espdiff - apply the appropriate transformation to a set of + espdiff + apply the appropriate transformation to a set of patches - - - espdiff - --deep-brainwave-mode - --recurse - --compare - file - - - - espdiff - - --help - --version - - + + espdiff + --deep-brainwave-mode + --recurse + --compare + + file + + + + espdiff + + --help + --version + + - - Description - - espdiff applies the appropriate + Description + espdiff applies the appropriate transformation to a patch or set of patches, depending on what you intend to accomplish. - - The input patches must be clean: in other + The input patches must be clean: in other words they must apply without fuzz or offsets in whichever order they are meant to be applied. The exception is if you intend espdiff to clean them for you (good luck). - - You may find it useful to cross your fingers while the + You may find it useful to cross your fingers while the program performs its task, or to screw your eyes tight shut while imagining it doing the right thing. - - Options - - - - - - Probes your brain deeply in a manner that takes + Options + + + + + + + Probes your brain deeply in a manner that takes longer, but produces better extra sensory results. - - - - - - - Recurses neural pathways throughout all parts of + + + + + + + + Recurses neural pathways throughout all parts of the brain, in some cases determining code changes you might make far off in the future. You may feel a gentle tickling sensation when using this option. - - - - - - - Allows the program to scan the current directory + + + + + + + + Allows the program to scan the current directory examining existing patches to determine areas of code you are likely to change again, and concentrating on these areas more closely. - - - - - - - Display a short usage message. - - - - - - - Display the version number of espdiff. - - - + + + + + + + + Display a short usage message. + + + + + + + + Display the version number of espdiff. + + + - - Limitations - - Do not use this program while sleep-walking, or before + Limitations + Do not use this program while sleep-walking, or before your first cup of coffee. - - There are some cases in which it is not possible to + There are some cases in which it is not possible to determine what the intention of the user is. In these cases, you should construct the output you desire using an editor, and send the input files together with the desired output