@matheusbsbs / matheus-bagliano / commits / ccb181d0f0
Fork 0

fast-import: use write_pack_header()

Call write_pack_header() to hash and write a pack header instead of open-coding this function. This gets rid of duplicate code and of the magic version number 2 -- which has been used here since c90be46abd (Changed fast-import's pack header creation to use pack.h, 2006-08-16) and in pack.h (again) since 29f049a0c2 (Revert "move pack creation to version 3", 2006-10-14). Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Sep 6, 2020 at 10:39 UTC ccb181d0f053100a988ee0a240e3c0c0bb962d4d
1 file changed +1 -7
builtin/fast-import.c
+1 -7
@@ -739,7 +739,6 @@ static void start_packfile(void)
739 {
740 struct strbuf tmp_file = STRBUF_INIT;
741 struct packed_git *p;
742 - struct pack_header hdr;
742 int pack_fd;
743
744 pack_fd = odb_mkstemp(&tmp_file, "pack/tmp_pack_XXXXXX");
@@ -750,13 +749,8 @@ static void start_packfile(void)
749 p->do_not_close = 1;
750 pack_file = hashfd(pack_fd, p->pack_name);
751
753 - hdr.hdr_signature = htonl(PACK_SIGNATURE);
754 - hdr.hdr_version = htonl(2);
755 - hdr.hdr_entries = 0;
756 - hashwrite(pack_file, &hdr, sizeof(hdr));
757 -
752 pack_data = p;
759 - pack_size = sizeof(hdr);
753 + pack_size = write_pack_header(pack_file, 0);
754 object_count = 0;
755
756 REALLOC_ARRAY(all_packs, pack_id + 1);