Fix performance bugs according to #47

No particular when calling checkout with a branch or version name, the Git client performed unnecessary fetches (if we just checked out, no need to fetch again), or other update operations that should not be necessary immediately after the initial clone.

I added unit tests counting the invocatino of fetch to prevent this in the future.

The code may be quite tough to review, as the logic for finding out what action to take in _do_update is not that clear, I admit. I considered refactoring more, but am scared of breaking code.