Code

Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 Jan 2012 07:33:39 +0000 (23:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jan 2012 07:33:39 +0000 (23:33 -0800)
* maint:
  Update draft release notes to 1.7.8.4
  Update draft release notes to 1.7.7.6
  Update draft release notes to 1.7.6.6
  thin-pack: try harder to use preferred base objects as base

1  2 
builtin/pack-objects.c

diff --combined builtin/pack-objects.c
index 96c1680976fc653a1cd7a9dd81a567885a5b0050,ef703dfeb611c0820a68f4c7cebae154689fa5f5..0f2e7b8f5cb26910679c39550d59ef23353a278f
@@@ -76,7 -76,7 +76,7 @@@ static struct pack_idx_option pack_idx_
  static const char *base_name;
  static int progress = 1;
  static int window = 10;
 -static unsigned long pack_size_limit, pack_size_limit_cfg;
 +static unsigned long pack_size_limit;
  static int depth = 50;
  static int delta_search_threads;
  static int pack_to_stdout;
@@@ -638,6 -638,7 +638,6 @@@ static void write_pack_file(void
        uint32_t i = 0, j;
        struct sha1file *f;
        off_t offset;
 -      struct pack_header hdr;
        uint32_t nr_remaining = nr_result;
        time_t last_mtime = 0;
        struct object_entry **write_order;
                unsigned char sha1[20];
                char *pack_tmp_name = NULL;
  
 -              if (pack_to_stdout) {
 +              if (pack_to_stdout)
                        f = sha1fd_throughput(1, "<stdout>", progress_state);
 -              } else {
 -                      char tmpname[PATH_MAX];
 -                      int fd;
 -                      fd = odb_mkstemp(tmpname, sizeof(tmpname),
 -                                       "pack/tmp_pack_XXXXXX");
 -                      pack_tmp_name = xstrdup(tmpname);
 -                      f = sha1fd(fd, pack_tmp_name);
 -              }
 +              else
 +                      f = create_tmp_packfile(&pack_tmp_name);
  
 -              hdr.hdr_signature = htonl(PACK_SIGNATURE);
 -              hdr.hdr_version = htonl(PACK_VERSION);
 -              hdr.hdr_entries = htonl(nr_remaining);
 -              sha1write(f, &hdr, sizeof(hdr));
 -              offset = sizeof(hdr);
 +              offset = write_pack_header(f, nr_remaining);
 +              if (!offset)
 +                      die_errno("unable to write pack header");
                nr_written = 0;
                for (; i < nr_objects; i++) {
                        struct object_entry *e = write_order[i];
  
                if (!pack_to_stdout) {
                        struct stat st;
 -                      const char *idx_tmp_name;
                        char tmpname[PATH_MAX];
  
 -                      idx_tmp_name = write_idx_file(NULL, written_list, nr_written,
 -                                                    &pack_idx_opts, sha1);
 -
 -                      snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
 -                               base_name, sha1_to_hex(sha1));
 -                      free_pack_by_name(tmpname);
 -                      if (adjust_shared_perm(pack_tmp_name))
 -                              die_errno("unable to make temporary pack file readable");
 -                      if (rename(pack_tmp_name, tmpname))
 -                              die_errno("unable to rename temporary pack file");
 -
                        /*
                         * Packs are runtime accessed in their mtime
                         * order since newer packs are more likely to contain
                         * packs then we should modify the mtime of later ones
                         * to preserve this property.
                         */
 -                      if (stat(tmpname, &st) < 0) {
 +                      if (stat(pack_tmp_name, &st) < 0) {
                                warning("failed to stat %s: %s",
 -                                      tmpname, strerror(errno));
 +                                      pack_tmp_name, strerror(errno));
                        } else if (!last_mtime) {
                                last_mtime = st.st_mtime;
                        } else {
                                struct utimbuf utb;
                                utb.actime = st.st_atime;
                                utb.modtime = --last_mtime;
 -                              if (utime(tmpname, &utb) < 0)
 +                              if (utime(pack_tmp_name, &utb) < 0)
                                        warning("failed utime() on %s: %s",
                                                tmpname, strerror(errno));
                        }
  
 -                      snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
 -                               base_name, sha1_to_hex(sha1));
 -                      if (adjust_shared_perm(idx_tmp_name))
 -                              die_errno("unable to make temporary index file readable");
 -                      if (rename(idx_tmp_name, tmpname))
 -                              die_errno("unable to rename temporary index file");
 -
 -                      free((void *) idx_tmp_name);
 +                      /* Enough space for "-<sha-1>.pack"? */
 +                      if (sizeof(tmpname) <= strlen(base_name) + 50)
 +                              die("pack base name '%s' too long", base_name);
 +                      snprintf(tmpname, sizeof(tmpname), "%s-", base_name);
 +                      finish_tmp_packfile(tmpname, pack_tmp_name,
 +                                          written_list, nr_written,
 +                                          &pack_idx_opts, sha1);
                        free(pack_tmp_name);
                        puts(sha1_to_hex(sha1));
                }
@@@ -1434,11 -1456,16 +1434,16 @@@ static int try_delta(struct unpacked *t
                return -1;
  
        /*
-        * We do not bother to try a delta that we discarded
-        * on an earlier try, but only when reusing delta data.
+        * We do not bother to try a delta that we discarded on an
+        * earlier try, but only when reusing delta data.  Note that
+        * src_entry that is marked as the preferred_base should always
+        * be considered, as even if we produce a suboptimal delta against
+        * it, we will still save the transfer cost, as we already know
+        * the other side has it and we won't send src_entry at all.
         */
        if (reuse_delta && trg_entry->in_pack &&
            trg_entry->in_pack == src_entry->in_pack &&
+           !src_entry->preferred_base &&
            trg_entry->in_pack_type != OBJ_REF_DELTA &&
            trg_entry->in_pack_type != OBJ_OFS_DELTA)
                return 0;
@@@ -2076,6 -2103,10 +2081,6 @@@ static int git_pack_config(const char *
                            pack_idx_opts.version);
                return 0;
        }
 -      if (!strcmp(k, "pack.packsizelimit")) {
 -              pack_size_limit_cfg = git_config_ulong(k, v);
 -              return 0;
 -      }
        return git_default_config(k, v, cb);
  }