Merge branch 'jk/sha1write-void'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Jan 2014 18:33:09 +0000 (10:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jan 2014 18:33:09 +0000 (10:33 -0800)
Code clean-up.

* jk/sha1write-void:
do not pretend sha1write returns errors

1  2 
csum-file.c
csum-file.h
pack-write.c
diff --combined csum-file.c
index 465971c7f303e29bf9501e6968da1ea71b5af76a,b30e4f28942e8fc8872f9dafa81efad5164691b8..b00b215031174a0f8ee3cd3d51c662d3cacc6b00
@@@ -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);
                }
                f->offset = offset;
        }
-       return 0;
  }
  
  struct sha1file *sha1fd(int fd, const char *name)
diff --combined csum-file.h
index 9dedb038ea9c77a8fadac370e039f1672e948325,6a55c7d729ee0e5073df7f7dfdef2f59275bfdaf..bb543d52f108cf1e976ee644e337f5ccec983790
@@@ -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 ddc174e1adb9e1545b2815d8a1990e43f6fa2bfb,676ed4ce9ad9f4fdfeaaaac13f91f8d0e8a95dae..605d01b25cbd9d796810f8aa810894a2c198da28
@@@ -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) {
        }
        sha1write(f, array, 256 * 4);
  
 -      /* compute the SHA1 hash of sorted object names. */
 -      git_SHA1_Init(&ctx);
 -
        /*
         * Write the actual SHA1 entries..
         */
                        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",
        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);
  }