Merge branch 'jk/unpack-entry-fallback-to-another'
authorJunio C Hamano <gitster@pobox.com>
Sun, 23 Jun 2013 21:53:20 +0000 (14:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 23 Jun 2013 21:53:20 +0000 (14:53 -0700)
* jk/unpack-entry-fallback-to-another:
unpack_entry: do not die when we fail to apply a delta
t5303: drop "count=1" from corruption dd

1  2 
sha1_file.c
diff --combined sha1_file.c
index 16f08d475cde5e96282aa830dd3373277c2b898f,742cf342c0478726e200e2635b8f48bc0aa36421..0af19c00f19b56b23bd7d4ad0f27fdd45cd06d90
@@@ -36,9 -36,6 +36,9 @@@ static inline uintmax_t sz_fmt(size_t s
  
  const unsigned char null_sha1[20];
  
 +static const char *no_log_pack_access = "no_log_pack_access";
 +static const char *log_pack_access;
 +
  /*
   * This is meant to hold a *small* number of objects that you would
   * want read_sha1_file() to be able to return, but yet you do not want
@@@ -1959,19 -1956,12 +1959,19 @@@ static void write_pack_access_log(struc
  {
        static FILE *log_file;
  
 +      if (!log_pack_access)
 +              log_pack_access = getenv("GIT_TRACE_PACK_ACCESS");
 +      if (!log_pack_access)
 +              log_pack_access = no_log_pack_access;
 +      if (log_pack_access == no_log_pack_access)
 +              return;
 +
        if (!log_file) {
                log_file = fopen(log_pack_access, "w");
                if (!log_file) {
                        error("cannot open pack access log '%s' for writing: %s",
                              log_pack_access, strerror(errno));
 -                      log_pack_access = NULL;
 +                      log_pack_access = no_log_pack_access;
                        return;
                }
        }
@@@ -2002,7 -1992,7 +2002,7 @@@ void *unpack_entry(struct packed_git *p
        int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
        int base_from_cache = 0;
  
 -      if (log_pack_access)
 +      if (log_pack_access != no_log_pack_access)
                write_pack_access_log(p, obj_offset);
  
        /* PHASE 1: drill down to the innermost base object */
                data = patch_delta(base, base_size,
                                   delta_data, delta_size,
                                   &size);
+               /*
+                * We could not apply the delta; warn the user, but keep going.
+                * Our failure will be noticed either in the next iteration of
+                * the loop, or if this is the final delta, in the caller when
+                * we return NULL. Those code paths will take care of making
+                * a more explicit warning and retrying with another copy of
+                * the object.
+                */
                if (!data)
-                       die("failed to apply delta");
+                       error("failed to apply delta");
  
                free(delta_data);
        }
@@@ -2358,7 -2357,7 +2367,7 @@@ static int sha1_loose_object_info(cons
  
        map = map_sha1_file(sha1, &mapsize);
        if (!map)
 -              return error("unable to find %s", sha1_to_hex(sha1));
 +              return -1;
        if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0)
                status = error("unable to unpack %s header",
                               sha1_to_hex(sha1));