Reuse sha1 in packed_git in fast-import.
Rather than maintaing our own packfile level sha1 variable we can make use of the one already available in struct packed_git. Its meant for the SHA1 of the index but it can also hold the SHA1 of the packfile itself between final checksumming of the packfile and creation of the index. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 16, 2007 at 00:44 UTC
09543c96bbe41d312bc002c293a193aa328c839d
1 file changed
+4
-5
fast-import.c
+4
-5
@@ -248,7 +248,6 @@ static struct packed_git *pack_data;
248
static struct packed_git **all_packs;
249
static int pack_fd;
250
static unsigned long pack_size;
251
-static unsigned char pack_sha1[20];
251
252
/* Table of objects we've written. */
253
static unsigned int object_entry_alloc = 5000;
@@ -646,8 +645,8 @@ static void fixup_header_footer()
645
}
646
free(buf);
647
649
- SHA1_Final(pack_sha1, &c);
650
- write_or_die(pack_fd, pack_sha1, sizeof(pack_sha1));
648
+ SHA1_Final(pack_data->sha1, &c);
649
+ write_or_die(pack_fd, pack_data->sha1, sizeof(pack_data->sha1));
650
}
651
652
static int oecmp (const void *a_, const void *b_)
@@ -697,8 +696,8 @@ static void write_index(const char *idx_name)
696
sha1write(f, &offset, 4);
697
sha1write(f, (*c)->sha1, sizeof((*c)->sha1));
698
}
700
- sha1write(f, pack_sha1, sizeof(pack_sha1));
701
- sha1close(f, NULL, 1);
699
+ sha1write(f, pack_data->sha1, sizeof(pack_data->sha1));
700
+ sha1close(f, pack_data->sha1, 1);
701
free(idx);
702
}
703