Created
October 11, 2014 01:07
-
-
Save pelya/b2e4d4f1ff361ba7b4b9 to your computer and use it in GitHub Desktop.
Split a 'normal' (non-unified) patch file with multiple files into separate small patches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| SPLITLINE="diff -r orig/" | |
| [ -n "$1" ] && SPLITLINE="$1" | |
| FILE= | |
| SPLITLEN=`echo $SPLITLINE | wc -c` | |
| while read LINE; do | |
| if echo $LINE | grep "^$SPLITLINE" > /dev/null; then | |
| FILE="`echo \"$LINE\" | tail -c +$SPLITLEN | sed 's@ .*@@'`" | |
| FILE="$FILE.patch" | |
| echo "Saving to file $FILE" | |
| else | |
| echo "$LINE" >> "$FILE" | |
| fi | |
| done | |
| echo "Now execute:" | |
| cat <<EOF | |
| find -name '*.patch' -exec sh -c 'echo {} | sed "s@\(.*\)[.]patch@\1 \1.patch@" | xargs patch -n' \; | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment