Re: [PATCH v2 2/3] object-file: emit corruption errors when detected
From: Junio C Hamano <hidden>
Date: 2022-12-07 01:16:08
Jonathan Tan [off-list ref] writes:
Instead of relying on errno being preserved across function calls, teach do_oid_object_info_extended() to itself report object corruption when it first detects it. There are 3 types of corruption being detected: - when a replacement object is missing - when a loose object is corrupt - when a packed object is corrupt and the object cannot be read in another way Note that in the RHS of this patch's diff, a check for ENOENT that was introduced in 3ba7a06552 (A loose object is not corrupt if it cannot be read due to EMFILE, 2010-10-28) is also removed. The purpose of this check is to avoid a false report of corruption if the errno contains something like EMFILE (or anything that is not ENOENT), in which case a more generic report is presented. Because, as of this patch, we no longer rely on such a heuristic to determine corruption, but surface the error message at the point when we read something that we did not expect, this check is no longer necessary. Besides being more resilient, this also prepares for a future patch in which an indirect caller of do_oid_object_info_extended() will need such functionality. Signed-off-by: Jonathan Tan <redacted> --- object-file.c | 63 ++++++++++++++++++++++++++------------------------ object-store.h | 3 +++ 2 files changed, 36 insertions(+), 30 deletions(-)
The implementation looks very straight-forward. Nicely done.