{"thread":{"id":"7540","subject":"[PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded","startedAt":"2007-04-05T22:39:24Z","lastAt":"2007-04-05T22:39:24Z","messageCount":1,"participants":["Dana How"],"isPatch":true,"patchVersion":1,"patchTotal":13},"messages":[{"id":"38752","messageId":"56b7f5510704051539p36ba3368xd827acd3fa4a3181@mail.gmail.com","threadId":"7540","inReplyTo":null,"subject":"[PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-04-05T22:39:24Z","receivedAt":"2007-04-05T22:39:24Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"---\n builtin-pack-objects.c |   26 ++++++++++++++++++++++++--\n 1 files changed, 24 insertions(+), 2 deletions(-)\n\n-- \nDana L. How  danahow@gmail.com  +1 650 804 5991 cell\n\n\nFrom d7d73a914e7c4587845ea0408d3e62fa44b4ac65 Mon Sep 17 00:00:00 2001\nFrom: Dana How <how@deathvalley.cswitch.com>\nDate: Thu, 5 Apr 2007 14:25:50 -0700\nSubject: [PATCH 11/13] implement write rollback in write_one() if --pack-limit exceeded\n\n---\n builtin-pack-objects.c |   26 ++++++++++++++++++++++++--\n 1 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex a243eed..ac643dd 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -511,15 +511,37 @@ 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-\tif (e->offset || e->preferred_base)\n+\tif (e->offset || e->preferred_base || e->no_write)\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 \te->offset = offset;\n+\tif (offset_limit) {\n+\t\t/* save state before write for possible later seekback */\n+\t\tstruct sha1posn posn;\n+\t\tuint32_t save_written = written, save_written_delta = written_delta;\n+\t\tuint32_t save_reused = reused, save_reused_delta = reused_delta;\n+\t\tsha1mark(f, &posn);\n+\t\toffset += write_object(f, e);\n+\t\t/*\n+\t\t * Ensure the packfile size never exceeds or matches offset_limit.\n+\t\t * The \"20\" is for the final SHA1.\n+\t\t */\n+\t\tif ((unsigned long)offset < (unsigned long)(offset_limit - 20))\n+\t\t\treturn offset;\n+\t\twritten = save_written, written_delta = save_written_delta;\n+\t\treused = save_reused, reused_delta = save_reused_delta;\n+\t\tsha1undo(f, &posn, offset, e->offset);\n+\t\te->offset = 0;\n+\t\treturn 0;\n+\t}\n \treturn offset + write_object(f, e);\n }\n \n-- \n1.5.1.rc2.18.g9c88-dirty\n\n"}]}