Created
October 10, 2012 14:04
-
-
Save valtoni/3865836 to your computer and use it in GitHub Desktop.
[unix] Patching directory: origin to target (exclude .svn dirs)
This file contains 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 | |
# IMPORTANT: SOURCE and TARGET are relative to ACTUAL_DIR. Whathever, the patch won't work. | |
ACTUAL_DIR=$(pwd) | |
PATCH_FILE="$ACTUAL_DIR/diff.patch" | |
PATCH_FILE_TMP="$PATCH_FILE.tmp" | |
SOURCE=$1 | |
TARGET=$2 | |
# Make the patch | |
diff --exclude=".svn" -uNr $SOURCE $TARGET > $PATCH_FILE_TMP | |
# Convert windows format to linux format | |
tr -d '\r' < $PATCH_FILE_TMP > $PATCH_FILE | |
# Exclude temp file | |
rm $PATCH_FILE_TMP | |
# Enter in target dir | |
cd $TARGET | |
# Apply patch in target dir | |
patch -R -p1 < $PATCH_FILE | |
# Enter in original dir | |
cd $ACTUAL_DIR | |
# Remove patch file | |
rm $PATCH_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment