Skip to content

Instantly share code, notes, and snippets.

@piccaso
Last active August 29, 2015 14:22
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 piccaso/431d30e5c979e3d2ba1f to your computer and use it in GitHub Desktop.
Save piccaso/431d30e5c979e3d2ba1f to your computer and use it in GitHub Desktop.
# curl https://gist.githubusercontent.com/piccaso/431d30e5c979e3d2ba1f/raw | bash
# related: http://bit.ly/1AJNMRA http://git.io/vk9it
# clone somewhere...
cd `mktemp -d` && git clone https://git.typo3.org/Packages/TYPO3.CMS.git && cd TYPO3.CMS/
{
# setup/reset
WORKINGBRANCH="TYPO3_7-0"
REVERTTO="TYPO3_3-6-0FINAL"
alias rewindrepo="git reset --hard && git clean -dxf && git checkout master && git branch -f $WORKINGBRANCH origin/$WORKINGBRANCH && git checkout $WORKINGBRANCH"
rm -f ../00*.patch
# read-tree alias based on jthill's answer
rewindrepo
git config alias.revert-all 'read-tree -um HEAD'
git revert-all $REVERTTO
git commit -m 'revert-all method'
git format-patch --output-directory .. HEAD^
# read-tree by jthill
rewindrepo
git read-tree -um @ $REVERTTO
git commit -m 'read-tree -um @ method'
git format-patch --output-directory .. HEAD^
# read-tree index only method
rewindrepo
git read-tree $REVERTTO
#git checkout-index -fa && git clean -dxf # update working directory
git commit -m 'read-tree method'
git format-patch --output-directory .. HEAD^
# based on first answer from Reimer Behrends
# modified to reattach HEAD
rewindrepo
BRANCH=$(git symbolic-ref --short -q HEAD)
git checkout TYPO3_3-6-0FINAL
git reset --soft TYPO3_7-0 # leaves HEAD detached
git commit -m "reset --soft method"
git branch -f $BRANCH HEAD
git checkout $BRANCH
git format-patch --output-directory .. HEAD^
# second answer from Reimer Behrends - missing some files...
rewindrepo
git checkout TYPO3_3-6-0FINAL .
#git reset --mixed
git commit -m "checkout <commit> . method"
git format-patch --output-directory .. HEAD^
# based on the answer from Reimer Behrends
# modified to reattach HEAD
rewindrepo
BRANCH=$(git symbolic-ref --short -q HEAD)
git checkout TYPO3_3-6-0FINAL
git reset --soft TYPO3_7-0 # leaves HEAD detached
git commit -m "reset --soft method"
git branch -f $BRANCH HEAD
git checkout $BRANCH
git format-patch --output-directory .. HEAD^
# apply-diff method, gives warnigs about whitespaces
# but still generates correct patch
rewindrepo
git diff --cached --full-index --binary $REVERTTO | git apply --reverse --cached
#git checkout-index -fa && git clean -dxf # update working directory
git commit -m 'apply-diff method'
git format-patch --output-directory .. HEAD^
# strip headers and calculate checksums
sed -e '1,6d' -i ../000*.patch
sha1sum ../00*.patch
# compare affected files
for f in ../00*.patch; do grep 'diff --git a/' $f > "$f.files"; done
sha1sum ../00*.files
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment