Inter-revision diff: patch 14

Comparing v2 (message) to v1 (message)

--- v2
+++ v1
@@ -1,50 +1,43 @@
 Remove direct manipulation of the 'struct revindex_entry' type as well
 as calls to the deprecated API in 'packfile.c:unpack_entry()'. Usual
 clean-up is performed (replacing '->nr' with calls to
-'pack_pos_to_index()' and so on).
-
-Add an additional check to make sure that 'obj_offset()' points at a
-valid object. In the case this check is violated, we cannot call
-'mark_bad_packed_object()' because we don't know the OID. At the top of
-the call stack is do_oid_object_info_extended() (via
-packed_object_info()), which does mark the object.
+'pack_pos_to_index()' and so on). Add an additional check to make
+sure that 'obj_offset()' points at a valid object.
 
 Signed-off-by: Taylor Blau <me@ttaylorr.com>
 ---
- packfile.c | 26 ++++++++++++++++++--------
- 1 file changed, 18 insertions(+), 8 deletions(-)
+ packfile.c | 24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
 
 diff --git a/packfile.c b/packfile.c
-index bb4bb14671..936ab3def5 100644
+index 469c8d4f57..34467ea4a3 100644
 --- a/packfile.c
 +++ b/packfile.c
-@@ -1694,11 +1694,21 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
+@@ -1692,11 +1692,19 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
  		}
  
  		if (do_check_packed_object_crc && p->index_version > 1) {
 -			struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
 -			off_t len = revidx[1].offset - obj_offset;
 -			if (check_pack_crc(p, &w_curs, obj_offset, len, revidx->nr)) {
-+			uint32_t pack_pos, index_pos;
++			uint32_t pos, nr;
 +			off_t len;
 +
-+			if (offset_to_pack_pos(p, obj_offset, &pack_pos) < 0) {
-+				error("could not find object at offset %"PRIuMAX" in pack %s",
-+				      (uintmax_t)obj_offset, p->pack_name);
++			if (offset_to_pack_pos(p, obj_offset, &pos) < 0) {
 +				data = NULL;
 +				goto out;
 +			}
 +
-+			len = pack_pos_to_offset(p, pack_pos + 1) - obj_offset;
-+			index_pos = pack_pos_to_index(p, pack_pos);
-+			if (check_pack_crc(p, &w_curs, obj_offset, len, index_pos)) {
++			len = pack_pos_to_offset(p, pos + 1) - obj_offset;
++			nr = pack_pos_to_index(p, pos);
++			if (check_pack_crc(p, &w_curs, obj_offset, len, nr)) {
  				struct object_id oid;
 -				nth_packed_object_id(&oid, p, revidx->nr);
-+				nth_packed_object_id(&oid, p, index_pos);
++				nth_packed_object_id(&oid, p, nr);
  				error("bad packed object CRC for %s",
  				      oid_to_hex(&oid));
  				mark_bad_packed_object(p, oid.hash);
-@@ -1781,11 +1791,11 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
+@@ -1779,11 +1787,11 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
  			 * This is costly but should happen only in the presence
  			 * of a corrupted pack, and is better than failing outright.
  			 */
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help