diff --git a/scripts/renamepatches b/scripts/renamepatches index fa2b5bc..8292b69 100755 --- a/scripts/renamepatches +++ b/scripts/renamepatches @@ -29,15 +29,20 @@ fi branch=$1 trap 'rm -f "$temp"' EXIT temp=$(mktemp) -git grep -iE '^(Git-commit:|No-fix:|\(cherry picked from commit)' $branch | grep -vF patches.kernel.org > $temp +git grep -iE '^(Git-commit:|No-fix:|\(cherry picked from commit)' $branch | tr ':' ' ' | \ + awk '!/patches.kernel.org/ {fn=$2; hash=$NF; map[hash]=map[hash] fn;} + END { for (hash in map) printf("map[%s]=\"%s\"\n", hash, map[hash]); }' \ + >$temp + +declare -A map +source $temp grep -E "^[[:space:]]*patches\.[a-z]+\/" < series.conf | while read patch ; do [ ! -f "$patch" ] && continue commit="$(awk -v IGNORECASE=1 '/^(Git-commit|No-fix):/ { print $2} /^\(cherry picked from commit/ { print $5}' $patch)" - [ -n "$commit" ] && echo "$commit" | while read c ; do - grep -F $c < $temp | tr ':' ' ' | while read junk fn blah ; do - [ -n "$fn" ] && [ $fn != $patch ] && git mv $patch $fn && sed -i -e "s,$patch,$fn," series.conf - done - done + [ -z "$commit" ] && continue + for fn in ${map[$commit]} ; do + [ $fn != $patch ] && git mv $patch $fn && sed -i -e "s,$patch,$fn," series.conf + done done