diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-16 22:33:40 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-16 22:33:40 -0800 |
commit | 48b303675aa238c209e527feadcbb7ba1c025c97 (patch) | |
tree | 6a48f4388867f836db0e4c015098348079a9185d /csum-file.c | |
parent | e45c9b03c32620c444f464403c23534160998624 (diff) | |
parent | 568508e76570e9ea36aad6446959424cebcf0535 (diff) | |
download | git-48b303675aa238c209e527feadcbb7ba1c025c97.tar.gz |
Merge branch 'jc/stream-to-pack'
* jc/stream-to-pack:
bulk-checkin: replace fast-import based implementation
csum-file: introduce sha1file_checkpoint
finish_tmp_packfile(): a helper function
create_tmp_packfile(): a helper function
write_pack_header(): a helper function
Conflicts:
pack.h
Diffstat (limited to 'csum-file.c')
-rw-r--r-- | csum-file.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/csum-file.c b/csum-file.c index fc97d6e045..53f5375b6c 100644 --- a/csum-file.c +++ b/csum-file.c @@ -158,6 +158,26 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp return f; } +void sha1file_checkpoint(struct sha1file *f, struct sha1file_checkpoint *checkpoint) +{ + sha1flush(f); + checkpoint->offset = f->total; + checkpoint->ctx = f->ctx; +} + +int sha1file_truncate(struct sha1file *f, struct sha1file_checkpoint *checkpoint) +{ + off_t offset = checkpoint->offset; + + if (ftruncate(f->fd, offset) || + lseek(f->fd, offset, SEEK_SET) != offset) + return -1; + f->total = offset; + f->ctx = checkpoint->ctx; + f->offset = 0; /* sha1flush() was called in checkpoint */ + return 0; +} + void crc32_begin(struct sha1file *f) { f->crc32 = crc32(0, NULL, 0); |