diff options
| author | Vicent Martà <tanoku@gmail.com> | 2012-04-19 11:40:56 -0700 |
|---|---|---|
| committer | Vicent Martà <tanoku@gmail.com> | 2012-04-19 11:40:56 -0700 |
| commit | d59305544e4825a7668d6d2fa9df2a0ffa21a3d6 (patch) | |
| tree | 4ffce3f8c3e384ad8b1a242caed33e601626a123 /src/filebuf.c | |
| parent | 54e4d0f25b4a957fba23dee4119dff9427151b90 (diff) | |
| parent | 1c9c081a6a0e02ea8a148717083e3f7a769c5a2e (diff) | |
| download | libgit2-d59305544e4825a7668d6d2fa9df2a0ffa21a3d6.tar.gz | |
Merge remote-tracking branch 'carlosmn/indexer-stream' into new-error-handling
Diffstat (limited to 'src/filebuf.c')
| -rw-r--r-- | src/filebuf.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/filebuf.c b/src/filebuf.c index a9de165d5..6538aea66 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -194,14 +194,19 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags) memset(file, 0x0, sizeof(git_filebuf)); + if (flags & GIT_FILEBUF_DO_NOT_BUFFER) + file->do_not_buffer = true; + file->buf_size = WRITE_BUFFER_SIZE; file->buf_pos = 0; file->fd = -1; file->last_error = BUFERR_OK; /* Allocate the main cache buffer */ - file->buffer = git__malloc(file->buf_size); - GITERR_CHECK_ALLOC(file->buffer); + if (!file->do_not_buffer) { + file->buffer = git__malloc(file->buf_size); + GITERR_CHECK_ALLOC(file->buffer); + } /* If we are hashing on-write, allocate a new hash context */ if (flags & GIT_FILEBUF_HASH_CONTENTS) { @@ -345,6 +350,9 @@ int git_filebuf_write(git_filebuf *file, const void *buff, size_t len) ENSURE_BUF_OK(file); + if (file->do_not_buffer) + return file->write(file, (void *)buff, len); + for (;;) { size_t space_left = file->buf_size - file->buf_pos; |
