{"thread":{"id":"12092","subject":"[PATCH 4/5] Finish current packfile during fast-import crash handler","startedAt":"2008-02-14T06:34:43Z","lastAt":"2008-02-14T06:34:43Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"68714","messageId":"20080214063443.GD30678@spearce.org","threadId":"12092","inReplyTo":null,"subject":"[PATCH 4/5] Finish current packfile during fast-import crash handler","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-02-14T06:34:43Z","receivedAt":"2008-02-14T06:34:43Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If fast-import is in the middle of crashing due to a protocol error\nor something like that then it can be very useful to have the mark\ntable and all objects up until that point be available for a new\nimport to resume from.\n\nCurrently we just close the active packfile, unkeep all of our\nnewly created packfiles (so they can be deleted), and dump the\nmarks table to a temporary file.\n\nWe don't attempt to update the refs/tags that the process has in\nmemory as much of that data can be found in the crash report and I'm\nnot sure it would be the right thing to do under every type of crash.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n fast-import.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 117f38c..0d3449f 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -459,6 +459,10 @@ static void write_crash_report(const char *err)\n \tfclose(rpt);\n }\n \n+static void end_packfile(void);\n+static void unkeep_all_packs(void);\n+static void dump_marks(void);\n+\n static NORETURN void die_nicely(const char *err, va_list params)\n {\n \tstatic int zombie;\n@@ -472,6 +476,9 @@ static NORETURN void die_nicely(const char *err, va_list params)\n \tif (!zombie) {\n \t\tzombie = 1;\n \t\twrite_crash_report(message);\n+\t\tend_packfile();\n+\t\tunkeep_all_packs();\n+\t\tdump_marks();\n \t}\n \texit(128);\n }\n-- \n1.5.4.1.1309.g833c2\n"}]}