scummvm/scummvm — pull request #119 by alexbevi (2011-11-16 11:19:19+00:00)
Title: Picture Engine

This is the Picture engine that MD5 announced a couple days ago on -devel.

Since this was originally an SVN to Git migration with the engine being developed in trunk, the engine needed to be incorporated into the project history in the proper subdirectory.

Below are the steps I used. I'm providing them here as they may prove useful to others in future endeavours, and also for more seasoned Git users to evaluate whether I've missed anything ;)

1) Clone the engine locally

git clone git://github.com/bluegr/scummvm-picture.git

2) Move the repository from */* to *engines/picture* and rewrite history accordingly

git filter-branch --index-filter \
'git ls-files -s | sed "s-\t\"*-&engines/picture/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD

3) Clean the commit messages to conform with the ScummVM standard

Since all commits should be prefixed with *ENGINE:*, scan and rewrite the history as necesary:

git filter-branch -f --msg-filter '
i=0
while read line
do
if [ $i -eq 0 ];
then
if expr "$line" : ".*PICTURE:.*" > /dev/null;
then
echo "$line"
else
echo "$line" | sed "s/^/PICTURE: /g"
fi
else
echo "$line"
fi
i=1
done ' HEAD

Note that this is only relevant for engines that don't touch any other areas of the project (all commits relate to the engine only).

4) From the main ScummVM repository, add the new (local) engine as a remote

git remote add picture ../scummvm-picture

5) Create a branch off of master and merge the engine

git checkout master
git checkout -b picture
git fetch picture
git merge picture/master

6) Rebase

Ensure the engine rebases cleanly onto master

git rebase -i master

7) Clean up Committer details

Since we don't want each commit in the branch to appear as if it were committed by me, remove those details . First, we need the hash of the first commit in the engine. I usually just do

git rebase -i master

again, then copy the first value and cancel the rebase.

>pick cdfb7f6 PICTURE: Initial checkin

Now we actually clean the history:

git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "Alex Bevilacqua" ];
then
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME";
GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL";
git commit-tree "$@";
else
git commit-tree "$@";
fi' cdfb7f6~..HEAD