X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-pack-objects.c;h=e1d3adf405bb6ac842a3415e0461b4772396060d;hb=5f8a0de98b727b9bfaea0f3318066109fd6745b8;hp=890f45cf2070a476c0325033e898e9345091fef1;hpb=668993ff19477652d793385b4f27a62891bcd3da;p=git.git diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 890f45cf2..e1d3adf40 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -17,7 +17,7 @@ #include "progress.h" #include "refs.h" -#ifdef THREADED_DELTA_SEARCH +#ifndef NO_PTHREADS #include "thread-utils.h" #include #endif @@ -77,7 +77,7 @@ static int allow_ofs_delta; static const char *base_name; static int progress = 1; static int window = 10; -static uint32_t pack_size_limit, pack_size_limit_cfg; +static unsigned long pack_size_limit, pack_size_limit_cfg; static int depth = 50; static int delta_search_threads; static int pack_to_stdout; @@ -246,7 +246,7 @@ static unsigned long write_object(struct sha1file *f, type = entry->type; - /* write limit if limited packsize and not first object */ + /* apply size limit if limited packsize and not first object */ if (!pack_size_limit || !nr_written) limit = 0; else if (pack_size_limit <= write_offset) @@ -443,7 +443,7 @@ static int write_one(struct sha1file *f, /* offset is non zero if object is written already. */ if (e->idx.offset || e->preferred_base) - return 1; + return -1; /* if we are deltified, write out base object first. */ if (e->delta && !write_one(f, e->delta, offset)) @@ -525,7 +525,8 @@ static void write_pack_file(void) if (!pack_to_stdout) { mode_t mode = umask(0); struct stat st; - char *idx_tmp_name, tmpname[PATH_MAX]; + const char *idx_tmp_name; + char tmpname[PATH_MAX]; umask(mode); mode = 0444 & ~mode; @@ -569,7 +570,7 @@ static void write_pack_file(void) if (rename(idx_tmp_name, tmpname)) die_errno("unable to rename temporary index file"); - free(idx_tmp_name); + free((void *) idx_tmp_name); free(pack_tmp_name); puts(sha1_to_hex(sha1)); } @@ -586,19 +587,6 @@ static void write_pack_file(void) if (written != nr_result) die("wrote %"PRIu32" objects while expecting %"PRIu32, written, nr_result); - /* - * We have scanned through [0 ... i). Since we have written - * the correct number of objects, the remaining [i ... nr_objects) - * items must be either already written (due to out-of-order delta base) - * or a preferred base. Count those which are neither and complain if any. - */ - for (j = 0; i < nr_objects; i++) { - struct object_entry *e = objects + i; - j += !e->idx.offset && !e->preferred_base; - } - if (j) - die("wrote %"PRIu32" objects as expected but %"PRIu32 - " unwritten", written, j); } static int locate_object_entry_hash(const unsigned char *sha1) @@ -673,7 +661,7 @@ static void setup_delta_attr_check(struct git_attr_check *check) static struct git_attr *attr_delta; if (!attr_delta) - attr_delta = git_attr("delta", 5); + attr_delta = git_attr("delta"); check[0].attr = attr_delta; } @@ -1254,7 +1242,7 @@ static int delta_cacheable(unsigned long src_size, unsigned long trg_size, return 0; } -#ifdef THREADED_DELTA_SEARCH +#ifndef NO_PTHREADS static pthread_mutex_t read_mutex; #define read_lock() pthread_mutex_lock(&read_mutex) @@ -1379,7 +1367,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, /* * Handle memory allocation outside of the cache * accounting lock. Compiler will optimize the strangeness - * away when THREADED_DELTA_SEARCH is not defined. + * away when NO_PTHREADS is defined. */ free(trg_entry->delta_data); cache_lock(); @@ -1566,7 +1554,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size, free(array); } -#ifdef THREADED_DELTA_SEARCH +#ifndef NO_PTHREADS /* * The main thread waits on the condition that (at least) one of the workers @@ -1898,7 +1886,7 @@ static int git_pack_config(const char *k, const char *v, void *cb) if (delta_search_threads < 0) die("invalid number of threads specified (%d)", delta_search_threads); -#ifndef THREADED_DELTA_SEARCH +#ifdef NO_PTHREADS if (delta_search_threads != 1) warning("no threads support, ignoring %s", k); #endif @@ -2202,10 +2190,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) continue; } if (!prefixcmp(arg, "--max-pack-size=")) { - char *end; pack_size_limit_cfg = 0; - pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024; - if (!arg[16] || *end) + if (!git_parse_ulong(arg+16, &pack_size_limit)) usage(pack_usage); continue; } @@ -2226,7 +2212,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) delta_search_threads = strtoul(arg+10, &end, 0); if (!arg[10] || *end || delta_search_threads < 0) usage(pack_usage); -#ifndef THREADED_DELTA_SEARCH +#ifdef NO_PTHREADS if (delta_search_threads != 1) warning("no threads support, " "ignoring %s", arg); @@ -2345,9 +2331,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (!pack_to_stdout && !pack_size_limit) pack_size_limit = pack_size_limit_cfg; - if (pack_to_stdout && pack_size_limit) die("--max-pack-size cannot be used to build a pack for transfer."); + if (pack_size_limit && pack_size_limit < 1024*1024) { + warning("minimum pack size limit is 1 MiB"); + pack_size_limit = 1024*1024; + } if (!pack_to_stdout && thin) die("--thin cannot be used to build an indexable pack.");