diff options
| author | Ben Straub <bstraub@github.com> | 2012-07-16 12:06:23 -0700 |
|---|---|---|
| committer | Ben Straub <bstraub@github.com> | 2012-07-16 12:06:23 -0700 |
| commit | 9587895f572ad4808fb1746dd6510f92ec30c3a6 (patch) | |
| tree | 7de0a8d95aafa99901ad8221d7f7af5348897c13 /src/checkout.c | |
| parent | 41ad70d0a8d5bf294197be5da26411bc7aa33fcc (diff) | |
| download | libgit2-9587895f572ad4808fb1746dd6510f92ec30c3a6.tar.gz | |
Migrate code to git_filter_blob_contents.
Also removes the unnecessary check for filter
length, since git_filters_apply does the right
thing when there are none, and it's more efficient
than this.
Diffstat (limited to 'src/checkout.c')
| -rw-r--r-- | src/checkout.c | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/src/checkout.c b/src/checkout.c index 61e81c538..dc4e559e1 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -32,49 +32,12 @@ typedef struct tree_walk_data } tree_walk_data; -static int unfiltered_blob_contents(git_buf *out, git_repository *repo, const git_oid *blob_id) -{ - int retcode = GIT_ERROR; - git_blob *blob; - - if (!(retcode = git_blob_lookup(&blob, repo, blob_id))) - retcode = git_blob__getbuf(out, blob); - - return retcode; -} - -static int filtered_blob_contents(git_buf *out, git_repository *repo, const git_oid *oid, const char *path) -{ - int retcode = GIT_ERROR; - - git_buf unfiltered = GIT_BUF_INIT; - if (!unfiltered_blob_contents(&unfiltered, repo, oid)) { - git_vector filters = GIT_VECTOR_INIT; - int filter_count = git_filters_load(&filters, repo, - path, GIT_FILTER_TO_WORKTREE); - if (filter_count >= 0) { - git_buf_clear(out); - if (!filter_count) { - git_buf_put(out, git_buf_cstr(&unfiltered), git_buf_len(&unfiltered)); - retcode = 0; - } else { - retcode = git_filters_apply(out, &unfiltered, &filters); - } - } - - git_filters_free(&filters); - } - - git_buf_free(&unfiltered); - return retcode; -} - static int blob_contents_to_file(git_repository *repo, git_buf *fnbuf, const git_oid *id, int mode) { int retcode = GIT_ERROR; git_buf filteredcontents = GIT_BUF_INIT; - if (!filtered_blob_contents(&filteredcontents, repo, id, git_buf_cstr(fnbuf))) { + if (!git_filter_blob_contents(&filteredcontents, repo, id, git_buf_cstr(fnbuf))) { int fd = git_futils_creat_withpath(git_buf_cstr(fnbuf), GIT_DIR_MODE, mode); if (fd >= 0) { |
