diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 30165ed59..f114e07fc 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -5,6 +5,10 @@ PS1="$" basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" gpgsign="$(git config commit.gpgsign || echo "false")" +applycmd="git am --3way --ignore-whitespace" +# Windows detection to workaround ARG_MAX limitation +windows="$([[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]] && echo "true" || echo "false")" + echo "Rebuilding Forked projects.... " function applyPatch { @@ -38,11 +42,30 @@ function applyPatch { echo " Applying patches to $target..." git am --abort >/dev/null 2>&1 - git am --3way --ignore-whitespace "$basedir/${what_name}-Patches/"*.patch + + # Special case Windows handling because of ARG_MAX constraint + if [[ $windows == "true" ]]; then + echo " Using workaround for Windows ARG_MAX constraint" + find "$basedir/${what_name}-Patches/"*.patch -print0 | xargs -0 $applycmd + else + $applycmd "$basedir/${what_name}-Patches/"*.patch + fi + if [ "$?" != "0" ]; then echo " Something did not apply cleanly to $target." echo " Please review above details and finish the apply then" echo " save the changes with rebuildPatches.sh" + + # On Windows, finishing the patch apply will only fix the latest patch + # users will need to rebuild from that point and then re-run the patch + # process to continue + if [[ $windows == "true" ]]; then + echo "" + echo " Because you're on Windows you'll need to finish the AM," + echo " rebuild all patches, and then re-run the patch apply again." + echo " Consider using the scripts with Windows Subsystem for Linux." + fi + exit 1 else echo " Patches applied cleanly to $target"