X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-pack-objects.c;h=28207d9b3aee9f3e886384871a6632fbaf7eee4f;hb=653194758ee338b7c87d011007c532ed5cf68d45;hp=f43eb67016ee719d34d2e2f4ae8d77e1ec74b396;hpb=325566cc5d14a409bdbc76aac50344294961f143;p=git.git diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index f43eb6701..28207d9b3 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -209,28 +209,6 @@ static int check_pack_inflate(struct packed_git *p, stream.total_in == len) ? 0 : -1; } -static int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, - off_t offset, off_t len, unsigned int nr) -{ - const uint32_t *index_crc; - uint32_t data_crc = crc32(0, Z_NULL, 0); - - do { - unsigned int avail; - void *data = use_pack(p, w_curs, offset, &avail); - if (avail > len) - avail = len; - data_crc = crc32(data_crc, data, avail); - offset += avail; - len -= avail; - } while (len); - - index_crc = p->index_data; - index_crc += 2 + 256 + p->num_objects * (20/4) + nr; - - return data_crc != ntohl(*index_crc); -} - static void copy_pack_data(struct sha1file *f, struct packed_git *p, struct pack_window **w_curs, @@ -514,11 +492,14 @@ static void write_pack_file(void) * Did we write the wrong # entries in the header? * If so, rewrite it like in fast-import */ - if (pack_to_stdout || nr_written == nr_remaining) { - sha1close(f, sha1, 1); + if (pack_to_stdout) { + sha1close(f, sha1, CSUM_CLOSE); + } else if (nr_written == nr_remaining) { + sha1close(f, sha1, CSUM_FSYNC); } else { int fd = sha1close(f, NULL, 0); fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written); + fsync_or_die(fd, pack_tmp_name); close(fd); } @@ -1145,8 +1126,6 @@ static void get_object_details(void) sorted_by_offset[i] = objects + i; qsort(sorted_by_offset, nr_objects, sizeof(*sorted_by_offset), pack_offset_sort); - init_pack_revindex(); - for (i = 0; i < nr_objects; i++) check_object(sorted_by_offset[i]); @@ -1760,7 +1739,7 @@ static void prepare_pack(int window, int depth) free(delta_list); } -static int git_pack_config(const char *k, const char *v) +static int git_pack_config(const char *k, const char *v, void *cb) { if(!strcmp(k, "pack.window")) { window = git_config_int(k, v); @@ -1813,7 +1792,7 @@ static int git_pack_config(const char *k, const char *v) pack_size_limit_cfg = git_config_ulong(k, v); return 0; } - return git_default_config(k, v); + return git_default_config(k, v, cb); } static void read_object_list_from_stdin(void) @@ -2033,7 +2012,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) rp_av[1] = "--objects"; /* --thin will make it --objects-edge */ rp_ac = 2; - git_config(git_pack_config); + git_config(git_pack_config, NULL); if (!pack_compression_seen && core_compression_seen) pack_compression_level = core_compression_level;