From: Junio C Hamano Date: Tue, 24 Mar 2009 22:31:21 +0000 (-0700) Subject: Merge branch 'maint-1.6.1' into maint X-Git-Tag: v1.6.2.2~17 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b0de55541024a39ece47cf7a1eebdbde08ba978f?ds=inline;hp=-c Merge branch 'maint-1.6.1' into maint * maint-1.6.1: close_sha1_file(): make it easier to diagnose errors avoid possible overflow in delta size filtering computation --- b0de55541024a39ece47cf7a1eebdbde08ba978f diff --combined builtin-pack-objects.c index bcefa52c69,7234d76f6e..8ca46c8deb --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@@ -78,7 -78,7 +78,7 @@@ static int progress = 1 static int window = 10; static uint32_t pack_size_limit, pack_size_limit_cfg; static int depth = 50; -static int delta_search_threads = 1; +static int delta_search_threads; static int pack_to_stdout; static int num_preferred_base; static struct progress *progress_state; @@@ -1293,7 -1293,7 +1293,7 @@@ static int try_delta(struct unpacked *t max_size = trg_entry->delta_size; ref_depth = trg->depth; } - max_size = max_size * (max_depth - src->depth) / + max_size = (uint64_t)max_size * (max_depth - src->depth) / (max_depth - ref_depth + 1); if (max_size == 0) return 0; @@@ -1611,18 -1611,11 +1611,18 @@@ static void ll_find_deltas(struct objec find_deltas(list, &list_size, window, depth, processed); return; } + if (progress > pack_to_stdout) + fprintf(stderr, "Delta compression using %d threads.\n", + delta_search_threads); /* Partition the work amongst work threads. */ for (i = 0; i < delta_search_threads; i++) { unsigned sub_size = list_size / (delta_search_threads - i); + /* don't use too small segments or no deltas will be found */ + if (sub_size < 2*window && i+1 < delta_search_threads) + sub_size = 0; + p[i].window = window; p[i].depth = depth; p[i].processed = processed; diff --combined sha1_file.c index 032300c4c6,3d93d936e4..a07aa4e5c4 --- a/sha1_file.c +++ b/sha1_file.c @@@ -801,7 -801,7 +801,7 @@@ unsigned char* use_pack(struct packed_g if (p->pack_fd == -1 && open_packed_git(p)) die("packfile %s cannot be accessed", p->pack_name); - /* Since packfiles end in a hash of their content and its + /* Since packfiles end in a hash of their content and it's * pointless to ask for an offset into the middle of that * hash, and the in_window function above wouldn't match * don't allow an offset too close to the end of the file. @@@ -1708,9 -1708,6 +1708,9 @@@ static void add_delta_base_cache(struc delta_base_cache_lru.prev = &ent->lru; } +static void *read_object(const unsigned char *sha1, enum object_type *type, + unsigned long *size); + static void *unpack_delta_entry(struct packed_git *p, struct pack_window **w_curs, off_t curpos, @@@ -2141,8 -2138,8 +2141,8 @@@ int pretend_sha1_file(void *buf, unsign return 0; } -void *read_object(const unsigned char *sha1, enum object_type *type, - unsigned long *size) +static void *read_object(const unsigned char *sha1, enum object_type *type, + unsigned long *size) { unsigned long mapsize; void *map, *buf; @@@ -2301,7 -2298,7 +2301,7 @@@ static void close_sha1_file(int fd fsync_or_die(fd, "sha1 file"); fchmod(fd, 0444); if (close(fd) != 0) - die("unable to write sha1 file"); + die("error when closing sha1 file (%s)", strerror(errno)); } /* Size of directory component, including the ending '/' */