The code to output the tar format for git-archive always assumes we are writing directly to stdout. Let's factor out that bit of code so that we can put an in-process gzip filter in place. Signed-off-by: Jeff King <peff@xxxxxxxx> --- archive-tar.c | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/archive-tar.c b/archive-tar.c index cee06ce..b1aea87 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -10,6 +10,7 @@ static char block[BLOCKSIZE]; static unsigned long offset; +static void (*output)(const char *buf, unsigned long size); static int tar_umask = 002; @@ -17,7 +18,7 @@ static int tar_umask = 002; static void write_if_needed(void) { if (offset == BLOCKSIZE) { - write_or_die(1, block, BLOCKSIZE); + output(block, BLOCKSIZE); offset = 0; } } @@ -42,7 +43,7 @@ static void write_blocked(const void *data, unsigned long size) write_if_needed(); } while (size >= BLOCKSIZE) { - write_or_die(1, buf, BLOCKSIZE); + output(buf, BLOCKSIZE); size -= BLOCKSIZE; buf += BLOCKSIZE; } @@ -66,10 +67,10 @@ static void write_trailer(void) { int tail = BLOCKSIZE - offset; memset(block + offset, 0, tail); - write_or_die(1, block, BLOCKSIZE); + output(block, BLOCKSIZE); if (tail < 2 * RECORDSIZE) { memset(block, 0, offset); - write_or_die(1, block, BLOCKSIZE); + output(block, BLOCKSIZE); } } @@ -234,7 +235,7 @@ static int git_tar_config(const char *var, const char *value, void *cb) return git_default_config(var, value, cb); } -int write_tar_archive(struct archiver_args *args) +static int write_tar_archive_internal(struct archiver_args *args) { int err = 0; @@ -248,3 +249,14 @@ int write_tar_archive(struct archiver_args *args) write_trailer(); return err; } + +static void output_write(const char *buf, unsigned long len) +{ + write_or_die(1, buf, len); +} + +int write_tar_archive(struct archiver_args *args) +{ + output = output_write; + return write_tar_archive_internal(args); +} -- 1.7.6.rc1.37.g6d4ed.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html