[PATCH] index-pack: correctly initialize appended objects

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Schindelin <Johannes.Schindelin@...>
Cc: Junio C Hamano <gitster@...>, Nicolas Pitre <nico@...>, <spearce@...>, <git@...>
Date: Friday, July 25, 2008 - 1:13 pm

When index-pack completes a thin pack it appends objects to the pack.
Since the commit 92392b4(index-pack: Honor core.deltaBaseCacheLimit when
resolving deltas) such an object can be pruned in case of memory pressure.

To be able to re-read the object later, a few more fields have to be set.

Noticed by Pierre Habouzit.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Acked-by: Nicolas Pitre <nico@cam.org>
---

    On 2008.07.25 15:15:48 +0200, Johannes Schindelin wrote:
    > So, let's add the comment as Nico suggested, and set real_type,
    > too?

    OK, I hope the comment is what was expected. My lack of knowledge
    made we wonder what to write... :-/

    > (And it would be smashing if you could verify that the type is
    > indeed correctly set to non-delta...)

    Hm, we get the object via read_sha1_file, can that return a delta? I
    would not expect it to.  Sorry, never looked at those code paths
    (and don't have the time to investigate at the moment).

 index-pack.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/index-pack.c b/index-pack.c
index ac20a46..d757b07 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -699,6 +699,12 @@ static struct object_entry *append_obj_to_pack(
 	write_or_die(output_fd, header, n);
 	obj[0].idx.crc32 = crc32(0, Z_NULL, 0);
 	obj[0].idx.crc32 = crc32(obj[0].idx.crc32, header, n);
+	// This object comes from outside the thin pack, so we need to
+	// initialize the size and type fields
+	obj[0].hdr_size = n;
+	obj[0].size = size;
+	obj[0].type = type;
+	obj[0].real_type = type;
 	obj[1].idx.offset = obj[0].idx.offset + n;
 	obj[1].idx.offset += write_compressed(output_fd, buf, size, &obj[0].idx.crc32);
 	hashcpy(obj->idx.sha1, sha1);
-- 
1.6.0.rc0.14.g95f8.dirty
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] index-pack: correctly initialize appended objects, Johannes Schindelin, (Thu Jul 24, 1:32 pm)
Re: [PATCH] index-pack: correctly initialize appended objects, Johannes Schindelin, (Fri Jul 25, 9:15 am)
[PATCH] index-pack: correctly initialize appended objects, Björn, (Fri Jul 25, 1:13 pm)
Re: [PATCH] index-pack: correctly initialize appended objects, Johannes Schindelin, (Fri Jul 25, 11:04 pm)
Re: [PATCH] index-pack: correctly initialize appended objects, Shawn O. Pearce, (Fri Jul 25, 12:42 pm)
Re: [PATCH] index-pack: correctly initialize appended objects, Johannes Schindelin, (Fri Jul 25, 6:24 am)