Pulling from remote repositories

I'm starting work on the ability to pull (fetch and merge) from remote repositories. I'm opening this PR to track major milestones in my work. I'll post again when it's complete.

The first commit fixes a deficiency in the previous handling of remote callbacks that ended up making that code unsuitable for most things other than cloning.