diff options
Diffstat (limited to 'bin/convpatch')
-rwxr-xr-x | bin/convpatch | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bin/convpatch b/bin/convpatch new file mode 100755 index 0000000..2ebbcd8 --- /dev/null +++ b/bin/convpatch @@ -0,0 +1,44 @@ +#!/bin/sh -f + +# convpatch -- convert git diff -p output to pkgsrc patch + +IFS=' +' + +{ + echo '$NetBSD$' + echo + + # get patch description + if [ x"$1" = x"-i" ]; then + f=`mktemp -t ${0##*/}` || exit 1 + echo 'Edit patch description...' > $f + </dev/tty >/dev/tty vi $f + c=`cat $f` + if [ x"$c" != x"Edit patch description..." ]; then + printf '%s\n\n' "$c" + fi + rm $f + fi + + sed ' + /^diff/d; + /^index/d; + s/^--- .*/&/; + ' +} | +while read -r line; do + case "$line" in + diff*) ;; + index*) ;; + '--- a/'*) + file=${line#--- a/} + echo -n "--- $file.orig " + file=$(git rev-parse --show-toplevel)/$file + echo "$(stat -x "$file")" | sed -n 's/^Access: //p' ;; + '+++ b/'*) + echo "+++ ${line#+++ b/}" ;; + *) + echo "$line" ;; + esac +done |