Merge branch 'maint-1.6.1' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 24 Mar 2009 22:31:21 +0000 (15:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Mar 2009 22:31:21 +0000 (15:31 -0700)
* maint-1.6.1:
close_sha1_file(): make it easier to diagnose errors
avoid possible overflow in delta size filtering computation

1  2 
builtin-pack-objects.c
sha1_file.c
diff --combined builtin-pack-objects.c
index bcefa52c69481ceb301a96af6402ca2a029144fb,7234d76f6e7c0ca59964ec06bf3ced7196716749..8ca46c8deb09a4c7d32947033eab804b108e0a34
@@@ -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 032300c4c6434701e802df729cd74245e543de20,3d93d936e4e3ddf24f46af2ef92e62e5f7db3877..a07aa4e5c491d16f65bc109673e806e24efb2274
@@@ -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 '/' */