[PATCH 6/8] git-repack --max-pack-size: write_one() implements limits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If --max-pack-size (offset_limit) is specified,
generate the appropriate write limit for each object and
pass it to write_object().  Detect and return
write "failure".

Signed-off-by: Dana How <how@xxxxxxxxxxxxxxxxxxxxxxx>
---
 builtin-pack-objects.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 9530008..a088f2e 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -556,16 +556,24 @@ static off_t write_one(struct sha1file *f,
 			       struct object_entry *e,
 			       off_t offset)
 {
+	off_t result;
 	if (e->offset || e->preferred_base)
 		/* offset starts from header size and cannot be zero
 		 * if it is written already.
 		 */
 		return offset;
 	/* if we are deltified, write out its base object first. */
-	if (e->delta)
+	if (e->delta) {
 		offset = write_one(f, e->delta, offset);
+		if (!offset)
+			return offset;
+	}
+	/* pass in write limit if limited packsize and not first object */
+	result = write_object(f, e, offset_limit && nr_written ? offset_limit - offset : 0);
+	if (!result)
+		return result;
 	e->offset = offset;
-	return offset + write_object(f, e, 0);
+	return offset + result;
 }
 
 /*
-- 
1.5.1.89.g8abf0

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]