diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-26 20:27:56 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-26 20:27:56 -0700 |
commit | c38138cd78f284b261a02323e8f18a1dee87c7fa (patch) | |
tree | 0a356b92c85c4d545a9b83073a4a7c769c408251 /unpack-objects.c | |
parent | Add "--pretty=full" format that also shows committer. (diff) | |
download | tgif-c38138cd78f284b261a02323e8f18a1dee87c7fa.tar.xz |
git-pack-objects: write the pack files with a SHA1 csum
We want to be able to check their integrity later, and putting the
sha1-sum of the contents at the end is a good thing. The writing
routines are generic, so we could try to re-use them for the index file,
instead of having the same logic duplicated.
Update unpack-objects to know about the extra 20 bytes at the end
of the index.
Diffstat (limited to 'unpack-objects.c')
-rw-r--r-- | unpack-objects.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/unpack-objects.c b/unpack-objects.c index 9da3ac89a8..91a71c55c6 100644 --- a/unpack-objects.c +++ b/unpack-objects.c @@ -61,7 +61,7 @@ static int check_index(void) unsigned int nr; int i; - if (index_size < 4*256) + if (index_size < 4*256 + 20) return error("index file too small"); nr = 0; for (i = 0; i < 256; i++) { @@ -70,11 +70,14 @@ static int check_index(void) return error("non-monotonic index"); nr = n; } - if (index_size != 4*256 + nr * 24) { - printf("index_size=%lu, expected %u (%u)\n", - index_size, 4*256 + nr * 24, nr); + /* + * Total size: + * - 256 index entries 4 bytes each + * - 24-byte entries * nr (20-byte sha1 + 4-byte offset) + * - 20-byte SHA1 file checksum + */ + if (index_size != 4*256 + nr * 24 + 20) return error("wrong index file size"); - } nr_entries = nr; pack_list = xmalloc(nr * sizeof(struct pack_entry *)); |