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

Remove unnecessary pack_fd global in fast-import.

Much like the pack_sha1 the pack_fd is an unnecessary global variable, we already have the fd stored in our struct packed_git *pack_data so that the core library functions in sha1_file.c are able to lookup and decompress object data that we have previously written. Keeping an extra copy of this value in our own variable is just a hold-over from earlier versions of fast-import and is now completely unnecessary. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 16, 2007 at 01:20 UTC 0fcbcae75372f96539ba0f9598112c417d81ab0d
1 file changed +7 -6
fast-import.c
+7 -6
@@ -244,7 +244,6 @@ static struct atom_str **atom_table;
244 static unsigned int pack_id;
245 static struct packed_git *pack_data;
246 static struct packed_git **all_packs;
247 -static int pack_fd;
247 static unsigned long pack_size;
248
249 /* Table of objects we've written. */
@@ -592,6 +591,7 @@ static void start_packfile()
591 static char tmpfile[PATH_MAX];
592 struct packed_git *p;
593 struct pack_header hdr;
594 + int pack_fd;
595
596 snprintf(tmpfile, sizeof(tmpfile),
597 "%s/pack_XXXXXX", get_object_directory());
@@ -605,7 +605,7 @@ static void start_packfile()
605 hdr.hdr_signature = htonl(PACK_SIGNATURE);
606 hdr.hdr_version = htonl(2);
607 hdr.hdr_entries = 0;
608 - write_or_die(pack_fd, &hdr, sizeof(hdr));
608 + write_or_die(p->pack_fd, &hdr, sizeof(hdr));
609
610 pack_data = p;
611 pack_size = sizeof(hdr);
@@ -617,6 +617,7 @@ static void start_packfile()
617
618 static void fixup_header_footer()
619 {
620 + int pack_fd = pack_data->pack_fd;
621 SHA_CTX c;
622 char hdr[8];
623 unsigned long cnt;
@@ -912,23 +913,23 @@ static int store_object(
913 last->depth++;
914
915 hdrlen = encode_header(OBJ_OFS_DELTA, deltalen, hdr);
915 - write_or_die(pack_fd, hdr, hdrlen);
916 + write_or_die(pack_data->pack_fd, hdr, hdrlen);
917 pack_size += hdrlen;
918
919 hdr[pos] = ofs & 127;
920 while (ofs >>= 7)
921 hdr[--pos] = 128 | (--ofs & 127);
921 - write_or_die(pack_fd, hdr + pos, sizeof(hdr) - pos);
922 + write_or_die(pack_data->pack_fd, hdr + pos, sizeof(hdr) - pos);
923 pack_size += sizeof(hdr) - pos;
924 } else {
925 if (last)
926 last->depth = 0;
927 hdrlen = encode_header(type, datlen, hdr);
927 - write_or_die(pack_fd, hdr, hdrlen);
928 + write_or_die(pack_data->pack_fd, hdr, hdrlen);
929 pack_size += hdrlen;
930 }
931
931 - write_or_die(pack_fd, out, s.total_out);
932 + write_or_die(pack_data->pack_fd, out, s.total_out);
933 pack_size += s.total_out;
934
935 free(out);