{"thread":{"id":"7575","subject":"[PATCH 6/8] git-repack --max-pack-size: write_one() implements limits","startedAt":"2007-04-08T23:25:17Z","lastAt":"2007-04-08T23:25:17Z","messageCount":1,"participants":["Dana How"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"38894","messageId":"461979DD.6030408@gmail.com","threadId":"7575","inReplyTo":null,"subject":"[PATCH 6/8] git-repack --max-pack-size: write_one() implements limits","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-04-08T23:25:17Z","receivedAt":"2007-04-08T23:25:17Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"\nIf --max-pack-size (offset_limit) is specified,\ngenerate the appropriate write limit for each object and\npass it to write_object().  Detect and return\nwrite \"failure\".\n\nSigned-off-by: Dana How <how@deathvalley.cswitch.com>\n---\n builtin-pack-objects.c |   12 ++++++++++--\n 1 files changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 9530008..a088f2e 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -556,16 +556,24 @@ static off_t write_one(struct sha1file *f,\n \t\t\t       struct object_entry *e,\n \t\t\t       off_t offset)\n {\n+\toff_t result;\n \tif (e->offset || e->preferred_base)\n \t\t/* offset starts from header size and cannot be zero\n \t\t * if it is written already.\n \t\t */\n \t\treturn offset;\n \t/* if we are deltified, write out its base object first. */\n-\tif (e->delta)\n+\tif (e->delta) {\n \t\toffset = write_one(f, e->delta, offset);\n+\t\tif (!offset)\n+\t\t\treturn offset;\n+\t}\n+\t/* pass in write limit if limited packsize and not first object */\n+\tresult = write_object(f, e, offset_limit && nr_written ? offset_limit - offset : 0);\n+\tif (!result)\n+\t\treturn result;\n \te->offset = offset;\n-\treturn offset + write_object(f, e, 0);\n+\treturn offset + result;\n }\n \n /*\n-- \n1.5.1.89.g8abf0\n"}]}