diff options
author | Russell Belfer <rb@github.com> | 2013-06-21 22:51:16 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-06-21 22:55:13 +0400 |
commit | 9094ae5a3c12ee99743498cb8e895d18b932e4dd (patch) | |
tree | d9018379bf5d6b784681f256ebd5186e0662688f /src/iterator.c | |
parent | 00197c34d6385a2de3970c9f820714064c5bf27f (diff) |
Add target directory to checkout
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 and the like.
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 #1332
Diffstat (limited to 'src/iterator.c')
-rw-r--r-- | src/iterator.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/iterator.c b/src/iterator.c index 76b0e41d0..5917f63fd 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -1321,9 +1321,10 @@ static void workdir_iterator__free(git_iterator *self) git_ignore__free(&wi->ignores); } -int git_iterator_for_workdir( +int git_iterator_for_workdir_ext( git_iterator **out, git_repository *repo, + const char *repo_workdir, git_iterator_flag_t flags, const char *start, const char *end) @@ -1331,8 +1332,11 @@ int git_iterator_for_workdir( int error; workdir_iterator *wi; - if (git_repository__ensure_not_bare(repo, "scan working directory") < 0) - return GIT_EBAREREPO; + if (!repo_workdir) { + if (git_repository__ensure_not_bare(repo, "scan working directory") < 0) + return GIT_EBAREREPO; + repo_workdir = git_repository_workdir(repo); + } /* initialize as an fs iterator then do overrides */ wi = git__calloc(1, sizeof(workdir_iterator)); @@ -1352,7 +1356,7 @@ int git_iterator_for_workdir( return error; } - return fs_iterator__initialize(out, &wi->fi, git_repository_workdir(repo)); + return fs_iterator__initialize(out, &wi->fi, repo_workdir); } |