Sync with GIT 1.6.2.5
authorJunio C Hamano <gitster@pobox.com>
Sun, 3 May 2009 23:46:34 +0000 (16:46 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 3 May 2009 23:55:38 +0000 (16:55 -0700)
1  2 
builtin-fetch-pack.c
diff --combined builtin-fetch-pack.c
index cbe5f206f5baab9868bc70028262aee611fba3f9,1effdc0d6b88c2a69ea36f18593556fc83a14fbf..87f46c6d07ccb0f82449b92e33cd4cda76a99da3
@@@ -13,6 -13,7 +13,7 @@@
  static int transfer_unpack_limit = -1;
  static int fetch_unpack_limit = -1;
  static int unpack_limit = 100;
+ static int prefer_ofs_delta = 1;
  static struct fetch_pack_args args = {
        /* .uploadpack = */ "git-upload-pack",
  };
@@@ -111,7 -112,7 +112,7 @@@ static void mark_common(struct commit *
    Get the next rev to send, ignoring the common.
  */
  
 -static const unsigned charget_rev(void)
 +static const unsigned char *get_rev(void)
  {
        struct commit *commit = NULL;
  
@@@ -200,7 -201,7 +201,7 @@@ static int find_common(int fd[2], unsig
                                     (args.use_thin_pack ? " thin-pack" : ""),
                                     (args.no_progress ? " no-progress" : ""),
                                     (args.include_tag ? " include-tag" : ""),
-                                    " ofs-delta");
+                                    (prefer_ofs_delta ? " ofs-delta" : ""));
                else
                        packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
                fetching++;
        if (args.depth > 0) {
                char line[1024];
                unsigned char sha1[20];
 -              int len;
  
 -              while ((len = packet_read_line(fd[0], line, sizeof(line)))) {
 +              while (packet_read_line(fd[0], line, sizeof(line))) {
                        if (!prefixcmp(line, "shallow ")) {
                                if (get_sha1_hex(line + 8, sha1))
                                        die("invalid shallow line: %s", line);
@@@ -482,7 -484,7 +483,7 @@@ static int sideband_demux(int fd, void 
  {
        int *xd = data;
  
 -      return recv_sideband("fetch-pack", xd[0], fd, 2);
 +      return recv_sideband("fetch-pack", xd[0], fd);
  }
  
  static int get_pack(int xd[2], char **pack_lockfile)
@@@ -596,6 -598,11 +597,11 @@@ static struct ref *do_fetch_pack(int fd
                        fprintf(stderr, "Server supports side-band\n");
                use_sideband = 1;
        }
+       if (server_supports("ofs-delta")) {
+               if (args.verbose)
+                       fprintf(stderr, "Server supports ofs-delta\n");
+       } else
+               prefer_ofs_delta = 0;
        if (everything_local(&ref, nr_match, match)) {
                packet_flush(fd[1]);
                goto all_done;
                        /* When cloning, it is not unusual to have
                         * no common commit.
                         */
 -                      fprintf(stderr, "warning: no common commits\n");
 +                      warning("no common commits");
  
        if (get_pack(fd, pack_lockfile))
                die("git fetch-pack: fetch failed.");
@@@ -648,6 -655,11 +654,11 @@@ static int fetch_pack_config(const cha
                return 0;
        }
  
+       if (strcmp(var, "repack.usedeltabaseoffset") == 0) {
+               prefer_ofs_delta = git_config_bool(var, value);
+               return 0;
+       }
        return git_default_config(var, value, cb);
  }
  
@@@ -800,13 -812,15 +811,13 @@@ struct ref *fetch_pack(struct fetch_pac
                int fd;
  
                mtime.sec = st.st_mtime;
 -#ifdef USE_NSEC
 -              mtime.usec = st.st_mtim.usec;
 -#endif
 +              mtime.nsec = ST_MTIME_NSEC(st);
                if (stat(shallow, &st)) {
                        if (mtime.sec)
                                die("shallow file was removed during fetch");
                } else if (st.st_mtime != mtime.sec
  #ifdef USE_NSEC
 -                              || st.st_mtim.usec != mtime.usec
 +                              || ST_MTIME_NSEC(st) != mtime.nsec
  #endif
                          )
                        die("shallow file was changed during fetch");