Skip to content

Commit ce2a79b

Browse files
committed
doc: improve grepdiff documentation with better examples and organization
Fix several issues with grepdiff documentation in patchutils.xml: * Move misplaced grepdiff example from filterdiff Examples section to grepdiff Examples section. The advanced example showing --output-matching=hunk with --as-numbered-lines was incorrectly placed in filterdiff documentation. * Clean up grepdiff Description section by removing embedded example that used a complex, inefficient pipeline (grepdiff | xargs filterdiff). Keep the section focused on conceptual explanation. * Completely rewrite grepdiff Examples section with comprehensive, progressive examples: - Start with filename-only output showing why it's useful for quick patch scanning - Show --output-matching=hunk for seeing actual matching hunks - Show --output-matching=file for complete file diffs - Include advanced usage with line numbering options - Preserve Git format example with explanatory notes * Add explanatory text for each example showing when and why to use each mode, making grepdiff's capabilities clearer These changes better showcase grepdiff as a powerful standalone tool rather than just a helper for filterdiff, with clear examples of its different output modes and proper organization of documentation. Assisted-by: Cursor
1 parent 551a06c commit ce2a79b

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

doc/patchutils.xml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,7 @@ patch.file]]></screen></para>
956956
<para>For CI/CD systems that need line numbers matching the original
957957
diff context (useful for error reporting), use the original-* variants:
958958

959-
<screen><![CDATA[grepdiff pattern --output-matching=hunk \
960-
--as-numbered-lines=original-after patch.file]]></screen></para>
959+
<screen><![CDATA[filterdiff --as-numbered-lines=original-after patch.file]]></screen></para>
961960
<para>Filterdiff can also be used to convert between unified
962961
and context format diffs:
963962

@@ -2100,12 +2099,6 @@ This is the same as gitdiff but uses git show instead of git diff.
21002099
are used instead of POSIX regular expressions, and the <option>-E</option>
21012100
option has no effect since PCRE already supports extended regular
21022101
expression features by default.</para>
2103-
<para>For example, to see the patches in
2104-
<filename>my.patch</filename> which contain the regular
2105-
expression <quote>pf_gfp_mask</quote>, use:
2106-
2107-
<screen><![CDATA[grepdiff pf_gfp_mask my.patch | \
2108-
xargs -rn1 filterdiff my.patch -i]]></screen></para>
21092102
<para>You can use unified, context, and Git format diffs with
21102103
this program. Git format includes support for binary files,
21112104
file renames, permission mode changes, and other Git-specific
@@ -2409,6 +2402,23 @@ This is the same as gitdiff but uses git show instead of git diff.
24092402
</refsect1>
24102403
<refsect1>
24112404
<title>Examples</title>
2405+
<para>To quickly identify which files in a large patch contain
2406+
memory allocation changes (useful for code review):
2407+
2408+
<screen><![CDATA[grepdiff "malloc\|free\|realloc" large-patch.diff]]></screen></para>
2409+
<para>This shows only the filenames, giving you a quick overview
2410+
without being overwhelmed by diff content.</para>
2411+
<para>To see the actual hunks containing the pattern:
2412+
2413+
<screen><![CDATA[grepdiff --output-matching=hunk "malloc" patch.diff]]></screen></para>
2414+
<para>To see complete file diffs for files containing the pattern:
2415+
2416+
<screen><![CDATA[grepdiff --output-matching=file "malloc" patch.diff]]></screen></para>
2417+
<para>For CI/CD systems that need line numbers matching the original
2418+
diff context (useful for error reporting):
2419+
2420+
<screen><![CDATA[grepdiff pattern --output-matching=hunk \
2421+
--as-numbered-lines=original-after patch.file]]></screen></para>
24122422
<para>Git format diffs are fully supported. For example, to find
24132423
files in a git patch that contain changes to malloc calls:
24142424

0 commit comments

Comments
 (0)