diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-09-29 15:49:28 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-09-29 15:49:28 +0200 |
| commit | c103d7b4b7e5fff1e5ec548ca24c16b1d2be33b8 (patch) | |
| tree | 25814d7265372d790c76b1c8d847f026a2d04570 /src | |
| parent | 8af4d074cc3bcc8ea63d75f147be892e4925075b (diff) | |
| download | libgit2-c103d7b4b7e5fff1e5ec548ca24c16b1d2be33b8.tar.gz | |
odb: Pass compression settings to filebuf
Diffstat (limited to 'src')
| -rw-r--r-- | src/filebuf.c | 9 | ||||
| -rw-r--r-- | src/filebuf.h | 2 | ||||
| -rw-r--r-- | src/odb_loose.c | 8 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/filebuf.c b/src/filebuf.c index bc1a8dceb..1a98e3f43 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -129,7 +129,7 @@ static int write_deflate(git_filebuf *file, void *source, size_t len) int git_filebuf_open(git_filebuf *file, const char *path, int flags) { - int error; + int error, compression; size_t path_len; assert(file && path); @@ -155,11 +155,12 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags) } } - /* If we are deflating on-write, */ - if (flags & GIT_FILEBUF_DEFLATE_CONTENTS) { + compression = flags >> GIT_FILEBUF_DEFLATE_SHIFT; + /* If we are deflating on-write, */ + if (compression != 0) { /* Initialize the ZLib stream */ - if (deflateInit(&file->zs, Z_BEST_SPEED) != Z_OK) { + if (deflateInit(&file->zs, compression) != Z_OK) { error = git__throw(GIT_EZLIB, "Failed to initialize zlib"); goto cleanup; } diff --git a/src/filebuf.h b/src/filebuf.h index d20881e9f..525ca3c81 100644 --- a/src/filebuf.h +++ b/src/filebuf.h @@ -19,7 +19,7 @@ #define GIT_FILEBUF_APPEND (1 << 2) #define GIT_FILEBUF_FORCE (1 << 3) #define GIT_FILEBUF_TEMPORARY (1 << 4) -#define GIT_FILEBUF_DEFLATE_CONTENTS (1 << 5) +#define GIT_FILEBUF_DEFLATE_SHIFT (5) #define GIT_FILELOCK_EXTENSION ".lock\0" #define GIT_FILELOCK_EXTLENGTH 6 diff --git a/src/odb_loose.c b/src/odb_loose.c index 4b2216bfd..80f0aa9e7 100644 --- a/src/odb_loose.c +++ b/src/odb_loose.c @@ -735,8 +735,8 @@ static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_ error = git_filebuf_open(&stream->fbuf, tmp_path, GIT_FILEBUF_HASH_CONTENTS | - GIT_FILEBUF_DEFLATE_CONTENTS | - GIT_FILEBUF_TEMPORARY); + GIT_FILEBUF_TEMPORARY | + (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT)); if (error < GIT_SUCCESS) { free(stream); @@ -774,8 +774,8 @@ static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const v error = git_filebuf_open(&fbuf, final_path, GIT_FILEBUF_HASH_CONTENTS | - GIT_FILEBUF_DEFLATE_CONTENTS | - GIT_FILEBUF_TEMPORARY); + GIT_FILEBUF_TEMPORARY | + (backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT)); if (error < GIT_SUCCESS) return error; |
