Saturday, September 25, 2010

A Fork of a Fork of a Fork

‹prev | My Chain | next›

I have a problem. A git problem.

A ways back, I got my animate frames plugin for raphaël.js working in my (fab) game. It was beautiful. Unfortunately, it was all very organic.

I forked the animate-frames stuff off a vows.js fork. It got me to the point that I could extract the animate frames out, but I never got it to the point that I could merge it back into master. I ultimately abandoned the fab.js work that drove the vows.js stuff that eventually spawned the animate frames work. But now I want just the animate frames stuff.

So how do I get that without the old fabjs and vowsjs stuff tagging along? It is only a half dozen commits, so I could cherry pick them. Since this seems like something that I will have to do again where cherry picking is not feasible (e.g. where there are many more than 6 commits involved), I think I will spend at least a little time trying to find another way.

So I head to google and find suggestions to use git merge (probably wouldn't work in my case) and, more interestingly, git checkout (it never would have occurred to me to try that).

But ultimately, I come across the advice to rebase --onto. Using that, I can rebase a branch, animate-frames in this case, to master, starting from the vowsjs fork. The command for that is blessedly simple:
cstrom@whitefall:~/repos/my_fab_game$ git rebase --onto master vowsjs animate-frames
First, rewinding head to replay your work on top of it...
Applying: Pull in the latest raphael-animate-frames
Applying: Switch room to raphael-animate-frames for drawing player avatar.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging javascript/room.js
CONFLICT (content): Merge conflict in javascript/room.js
Failed to merge in the changes.
Patch failed at 0002 Switch room to raphael-animate-frames for drawing player avatar.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
The command may be simple, but a lot has gone on in master since the animate-frames work. Happily that turns out to be the only problem. I address the issue in the javascript/room.js, put it back into the rebase staging area with git add javascript/room.js, then send rebase back on it merry way:
strom@whitefall:~/repos/my_fab_game$ git add javascript/room.js
cstrom@whitefall:~/repos/my_fab_game$ git rebase --continue
Applying: Switch room to raphael-animate-frames for drawing player avatar.
Applying: Use the raphael-animate-frames.js lib
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging html/board.html
Applying: Replace circle avatar calls with svg-frames equivalent
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging javascript/player.js
Applying: Use latest raphael-animate-frames
Applying: Use center() in raphael animate frames
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging javascript/player.js
With that, I have my animate-frames branch believing that it was forked from master only a few days ago:



The whole point of this is so that I can play with animated players on top of my node-dirty work from last night. I remain fairly certain that I am ready to move on with node-dirty instead of CouchDB, but a bit of play will help get the remaining doubt down to an acceptable minimum.

So I create a dirty-svg branch (naming is even more fun with dirty than with CouchDB!) and merge the animate frames branch into to it:
cstrom@whitefall:~/repos/my_fab_game$ git merge animate-frames 
Merge made by recursive.
html/board.html | 1 +
javascript/player.js | 30 +++-----
javascript/raphael-animate_frames.js | 136 ++++++++++++++++++++++++++++++++++
javascript/room.js | 58 ++++++++++++++-
4 files changed, 202 insertions(+), 23 deletions(-)
create mode 100644 javascript/raphael-animate_frames.js
Since both are (now) very recent forks from master, the merge goes through without objection. And, just like that, I am ready to start playing with animated-frame players on top of a node-dirty backend.

Tomorrow.


Day #237

No comments:

Post a Comment