From: Shawn O. Pearce Date: Fri, 10 Oct 2008 15:39:20 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.6.1-rc1~156 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e782e12f89955dfb0be82098af3cfdd8dd0eaf80;p=git.git Merge branch 'maint' * maint: rebase -i: do not fail when there is no commit to cherry-pick test-lib: fix color reset in say_color() fix pread()'s short read in index-pack Conflicts: csum-file.c --- e782e12f89955dfb0be82098af3cfdd8dd0eaf80 diff --cc csum-file.c index 717d29fc0,cfc1ac42b..2ddb12a0b --- a/csum-file.c +++ b/csum-file.c @@@ -11,8 -11,10 +11,8 @@@ #include "progress.h" #include "csum-file.h" - static void sha1flush(struct sha1file *f, void *buf, unsigned int count) -static void flush(struct sha1file *f, unsigned int count) ++static void flush(struct sha1file *f, void * buf, unsigned int count) { - void *buf = f->buffer; - for (;;) { int ret = xwrite(f->fd, buf, count); if (ret > 0) { @@@ -35,17 -37,23 +35,23 @@@ void sha1flush(struct sha1file *f unsigned offset = f->offset; if (offset) { - SHA1_Update(&f->ctx, f->buffer, offset); - flush(f, offset); + git_SHA1_Update(&f->ctx, f->buffer, offset); - sha1flush(f, f->buffer, offset); ++ flush(f, f->buffer, offset); f->offset = 0; } + } + + int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags) + { + int fd; + + sha1flush(f); - SHA1_Final(f->buffer, &f->ctx); + git_SHA1_Final(f->buffer, &f->ctx); if (result) hashcpy(result, f->buffer); if (flags & (CSUM_CLOSE | CSUM_FSYNC)) { /* write checksum and close fd */ - sha1flush(f, f->buffer, 20); - flush(f, 20); ++ flush(f, f->buffer, 20); if (flags & CSUM_FSYNC) fsync_or_die(f->fd, f->name); if (close(f->fd)) @@@ -82,8 -81,8 +88,8 @@@ int sha1write(struct sha1file *f, void buf = (char *) buf + nr; left -= nr; if (!left) { - SHA1_Update(&f->ctx, f->buffer, offset); - flush(f, offset); + git_SHA1_Update(&f->ctx, data, offset); - sha1flush(f, data, offset); ++ flush(f, data, offset); offset = 0; } f->offset = offset;