From: Junio C Hamano Date: Sun, 23 Jun 2013 21:53:20 +0000 (-0700) Subject: Merge branch 'jk/unpack-entry-fallback-to-another' X-Git-Tag: v1.8.4-rc0~145 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ee64e345b1ac13cbb9c6a2343453fa3fc798367a?ds=inline;hp=-c Merge branch 'jk/unpack-entry-fallback-to-another' * 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 --- ee64e345b1ac13cbb9c6a2343453fa3fc798367a diff --combined sha1_file.c index 16f08d475c,742cf342c0..0af19c00f1 --- a/sha1_file.c +++ b/sha1_file.c @@@ -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 */ @@@ -2145,8 -2135,17 +2145,17 @@@ 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));