On Wed, Jun 11, 2025 at 02:44:35PM -0400, Joe Lawrence wrote: > > +get_patch_files() { > > + local patch="$1" > > + > > + grep0 -E '^(--- |\+\+\+ )' "$patch" \ > > + | gawk '{print $2}' \ > > If we split the rest of this line on the tab character and print the > first part of $2: > > gawk '{ split($2, a, "\t"); print a[1] }' > > then it can additionally handle patches generated by `diff -Nupr` with a > timepstamp ("--- <filepath>\t<timestamp>").
Hm? The default gawk behavior is to treat both tabs and groups of spaces as field separators: https://www.gnu.org/software/gawk/manual/html_node/Default-Field-Splitting.html And it works for me: $ diff -Nupr /tmp/meminfo.c fs/proc/meminfo.c > /tmp/a.patch $ grep -E '^(--- |\+\+\+ )' /tmp/a.patch | gawk '{print $2}' /tmp/meminfo.c fs/proc/meminfo.c Or did I miss something? > > +# Refresh the patch hunk headers, specifically the line numbers and counts. > > +refresh_patch() { > > + local patch="$1" > > + local tmpdir="$PATCH_TMP_DIR" > > + local files=() > > + > > + rm -rf "$tmpdir" > > + mkdir -p "$tmpdir/a" > > + mkdir -p "$tmpdir/b" > > + > > + # Find all source files affected by the patch > > + grep0 -E '^(--- |\+\+\+ )[^ /]+' "$patch" | > > + sed -E 's/(--- |\+\+\+ )[^ /]+\///' | > > + sort | uniq | mapfile -t files > > + > > Should just call `get_patch_files() here? Indeed. -- Josh