filterdiff command examples

filterdiff command examples

filterdiff – extract or exclude diffs from a diff file

To see all patch hunks that affect the first five lines of a C file:

filterdiff -i '*.c' --lines=-5 < patch

To see the first hunk of each file patch, use:

filterdiff -#1 patchfile

To see patches modifying a ChangeLog file in a subdirectory, use:

filterdiff -p1 Changelog

To see the complete patches for each patch that modifies line 1 of the original file, use:

filterdiff --lines=1 patchfile | lsdiff | \
xargs -rn1 filterdiff patchfile -i

To see all but the first hunk of a particular patch, you might use:

filterdiff -p1 -i file.c -#2- foo-patch

If you have a very specific list of hunks in a patch that you want to see, list them:

filterdiff -#1,2,5-8,10,12,27-

To see the lines of the files that would be patched as they will appear after the patch is applied, use:

filterdiff --as-numbered-lines=after patch.file

You can see the same context before the patch is applied with:

filterdiff --as-numbered-lines=before

patch.file

Filterdiff can also be used to convert between unified and context format diffs:

filterdiff -v --format=unified context.diff

 

Leave a Reply

Your email address will not be published. Required fields are marked *