Add target directory to checkout options

This adds the ability for checkout to write to a target directory instead of having to use the working directory of the repository. This makes it easier to do exports of repository data or to extract a commit from a bare repo and so on. There is a new `target_directory` field in the `git_checkout_options` structure.

This is similar to, but not quite the same as, the `--prefix` option to `git checkout-index` (this will always be treated as a directory name, not just as a simple text prefix).

As part of this, the workdir iterator was extended to take the path to the working directory as a parameter and fallback on the `git_repository_workdir` result only if it's not specified.

Fixes issue #1332