From: Junio C Hamano Date: Fri, 10 Jan 2014 18:33:09 +0000 (-0800) Subject: Merge branch 'jk/sha1write-void' X-Git-Tag: v1.9-rc0~31 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f06a5e607dde266884db4a99b70fbee09d5c5efc?ds=inline;hp=-c Merge branch 'jk/sha1write-void' Code clean-up. * jk/sha1write-void: do not pretend sha1write returns errors --- f06a5e607dde266884db4a99b70fbee09d5c5efc diff --combined csum-file.c index 465971c7f3,b30e4f2894..b00b215031 --- a/csum-file.c +++ b/csum-file.c @@@ -11,7 -11,7 +11,7 @@@ #include "progress.h" #include "csum-file.h" -static void flush(struct sha1file *f, void *buf, unsigned int count) +static void flush(struct sha1file *f, const void *buf, unsigned int count) { if (0 <= f->check_fd && count) { unsigned char check_buffer[8192]; @@@ -86,13 -86,13 +86,13 @@@ int sha1close(struct sha1file *f, unsig return fd; } - int sha1write(struct sha1file *f, const void *buf, unsigned int count) -void sha1write(struct sha1file *f, void *buf, unsigned int count) ++void sha1write(struct sha1file *f, const void *buf, unsigned int count) { while (count) { unsigned offset = f->offset; unsigned left = sizeof(f->buffer) - offset; unsigned nr = count > left ? left : count; - void *data; + const void *data; if (f->do_crc) f->crc32 = crc32(f->crc32, buf, nr); @@@ -116,7 -116,6 +116,6 @@@ } f->offset = offset; } - return 0; } struct sha1file *sha1fd(int fd, const char *name) diff --combined csum-file.h index 9dedb038ea,6a55c7d729..bb543d52f1 --- a/csum-file.h +++ b/csum-file.h @@@ -34,7 -34,7 +34,7 @@@ extern struct sha1file *sha1fd(int fd, extern struct sha1file *sha1fd_check(const char *name); extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp); extern int sha1close(struct sha1file *, unsigned char *, unsigned int); - extern int sha1write(struct sha1file *, const void *, unsigned int); -extern void sha1write(struct sha1file *, void *, unsigned int); ++extern void sha1write(struct sha1file *, const void *, unsigned int); extern void sha1flush(struct sha1file *f); extern void crc32_begin(struct sha1file *); extern uint32_t crc32_end(struct sha1file *); diff --combined pack-write.c index ddc174e1ad,676ed4ce9a..605d01b25c --- a/pack-write.c +++ b/pack-write.c @@@ -44,13 -44,14 +44,13 @@@ static int need_large_offset(off_t offs */ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *opts, - unsigned char *sha1) + const unsigned char *sha1) { struct sha1file *f; struct pack_idx_entry **sorted_by_sha, **list, **last; off_t last_obj_offset = 0; uint32_t array[256]; int i, fd; - git_SHA_CTX ctx; uint32_t index_version; if (nr_objects) { @@@ -113,6 -114,9 +113,6 @@@ } sha1write(f, array, 256 * 4); - /* compute the SHA1 hash of sorted object names. */ - git_SHA1_Init(&ctx); - /* * Write the actual SHA1 entries.. */ @@@ -124,6 -128,7 +124,6 @@@ sha1write(f, &offset, 4); } sha1write(f, obj->sha1, 20); - git_SHA1_Update(&ctx, obj->sha1, 20); if ((opts->flags & WRITE_IDX_STRICT) && (i && !hashcmp(list[-2]->sha1, obj->sha1))) die("The same object %s appears twice in the pack", @@@ -173,6 -178,7 +173,6 @@@ sha1write(f, sha1, 20); sha1close(f, NULL, ((opts->flags & WRITE_IDX_VERIFY) ? CSUM_CLOSE : CSUM_FSYNC)); - git_SHA1_Final(sha1, &ctx); return index_name; } @@@ -183,8 -189,7 +183,7 @@@ off_t write_pack_header(struct sha1fil hdr.hdr_signature = htonl(PACK_SIGNATURE); hdr.hdr_version = htonl(PACK_VERSION); hdr.hdr_entries = htonl(nr_entries); - if (sha1write(f, &hdr, sizeof(hdr))) - return 0; + sha1write(f, &hdr, sizeof(hdr)); return sizeof(hdr); }