-
-
Save JoshRosen/50ca46c4a2e6c519695288cb0dc3ae37 to your computer and use it in GitHub Desktop.
Apply a patch file that was produced with "git format-patch" using the patch command, and commit it using the message from the original commit.
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/bash | |
apply () { | |
filename=$1 | |
shift | |
patch_args=$* | |
gotSubject=no | |
msg="" | |
cat $filename | while read line; do | |
if [ "$line" == "---" ]; then | |
patch $patch_args -p1 < $filename | |
git commit -a -m "$msg" | |
break | |
fi | |
if [ "$gotSubject" == "no" ]; then | |
hdr=(${line//:/ }) | |
if [ "${hdr[0]}" == "Subject" ]; then | |
gotSubject=yes | |
msg="${hdr[@]:3}" | |
fi | |
else | |
msg="$msg $line" | |
fi | |
done | |
} | |
apply $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment