twaugh / patchutils

Manipulate patch files
GNU General Public License v2.0
139 stars 22 forks source link

filterdiff should have an --in-place option #51

Open vapier opened 2 years ago

vapier commented 2 years ago

i often have to write loops like for x in *.patch; do filterdiff ... $x > f; mv f $x; done. would be super handy if i could just run filterdiff --in-place *.patch.

i picked --in-place because that's what sed uses. but -i is already taken by --include, so maybe it'd be -w --write with --in-place as an alias ?

mcepl commented 1 year ago

I have written this trivial script moddiff for the same purpose:

#!/bin/bash
set -eu

TEMPFILE=$(mktemp /tmp/moddiff.XXXXXX.patch)
trap 'rm -f $TEMPFILE' EXIT

ARGS=("$@")

filterdiff "${ARGS[@]}" >$TEMPFILE
mv $TEMPFILE "${ARGS[-1]}"

so I can then run something like (in fish):

for pf in *.patch
    moddiff -p1 -i 'lexers/*' -x '*.properties' $pf
end

I wouldn’t have a problem if it was included in this package, and just to be sure, I release this triviality to the public domain.