Skip to content

Instantly share code, notes, and snippets.

@ostrolucky
Created December 15, 2018 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ostrolucky/993ea7ea8464ea47832ac92e8c7b8388 to your computer and use it in GitHub Desktop.
Save ostrolucky/993ea7ea8464ea47832ac92e8c7b8388 to your computer and use it in GitHub Desktop.
Apply only changes which are mergeable to upper branch without conflicts
UPPERBRANCH=master
BOTTOMBRANCH=3.4
DIR="src"
git checkout $BOTTOMBRANCH
php-cs-fixer fix $DIR --rules='{"array_syntax": {"syntax": "short"}}'
git diff > patch.patch && splitpatch patch.patch && rm patch.patch
git checkout $UPPERBRANCH --force
mkdir -p nonworkingpatches workingpatches && rm -rf nonworkingpatches/* workingpatches/*
for patchfile in *.patch*; do
patch -s --force -p1 < $patchfile 1>/dev/null
if [[ $? -eq 0 ]]; then
cp $patchfile workingpatches/
fi
rm $patchfile
done
git checkout --force $BOTTOMBRANCH
git clean -fd $DIR
git checkout -b array_syntax
cat workingpatches/*|patch -s -p1
rm -rf workingpatches
git add $DIR
git commit -m "Use short array syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment