From cf82968f35c77c6e376d22b487616102321da326 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> Date: Wed, 16 May 2018 20:41:10 -0500 Subject: [PATCH] Apply workaround for patch application on Windows (#1122) This is not a perfect workaround but it seems to be the best solution for the moment. On Windows, this means that when a patch fails to apply, you would now need to fix that patch, finish the apply (AM), then rebuild all patches, and then finally re-run the patch apply procedure in order to continue. This adds a small amount of overhead compared to the traditional method (which will still work on *nix environments, including WSL). However, it seems preferable to the build not working on Windows at all. --- scripts/applyPatches.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 30165ed591..f114e07fc9 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"