{"thread":{"id":"7571","subject":"[PATCH 2/8] git-repack --max-pack-size: minor code restructuring","startedAt":"2007-04-08T23:20:29Z","lastAt":"2007-04-08T23:20:29Z","messageCount":1,"participants":["Dana How"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"38889","messageId":"461978BD.4080201@gmail.com","threadId":"7571","inReplyTo":null,"subject":"[PATCH 2/8] git-repack --max-pack-size: minor code restructuring","fromName":"Dana How","fromEmail":"danahow@gmail.com","sentAt":"2007-04-08T23:20:29Z","receivedAt":"2007-04-08T23:20:29Z","isPatch":true,"sender":{"key":"danahow@gmail.com","avatar":null},"body":"\nMove the call to write_index_file() from cmd_pack_objects()\nto write_pack_file() (since only the latter will know how\nmany times to call write_index_file()),  and move or add\nforward declarations for later changes.\n\nSigned-off-by: Dana How <how@deathvalley.cswitch.com>\n---\n builtin-pack-objects.c |   22 ++++++++++++++--------\n 1 files changed, 14 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 64318b3..8415549 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -518,6 +518,16 @@ static off_t write_one(struct sha1file *f,\n \treturn offset + write_object(f, e);\n }\n \n+typedef int (*entry_sort_t)(const struct object_entry *, const struct object_entry *);\n+\n+static entry_sort_t current_sort;\n+\n+/* forward declarations for write_pack_file */\n+/* (probably should move sorting stuff up here) */\n+static int sort_comparator(const void *_a, const void *_b);\n+static int sha1_sort(const struct object_entry *a, const struct object_entry *b);\n+static void write_index_file(void);\n+\n static void write_pack_file(void)\n {\n \tuint32_t i;\n@@ -562,6 +572,10 @@ static void write_pack_file(void)\n \tif (written != nr_result)\n \t\tdie(\"wrote %u objects while expecting %u\", written, nr_result);\n \tsha1close(f, pack_file_sha1, 1);\n+\tif (!pack_to_stdout) {\n+\t\twrite_index_file();\n+\t\tputs(sha1_to_hex(object_list_sha1));\n+\t}\n }\n \n static void write_index_file(void)\n@@ -1106,10 +1120,6 @@ static void get_object_details(void)\n \t}\n }\n \n-typedef int (*entry_sort_t)(const struct object_entry *, const struct object_entry *);\n-\n-static entry_sort_t current_sort;\n-\n static int sort_comparator(const void *_a, const void *_b)\n {\n \tstruct object_entry *a = *(struct object_entry **)_a;\n@@ -1698,10 +1708,6 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\t\tprogress_update = 0;\n \t\t}\n \t\twrite_pack_file();\n-\t\tif (!pack_to_stdout) {\n-\t\t\twrite_index_file();\n-\t\t\tputs(sha1_to_hex(object_list_sha1));\n-\t\t}\n \t}\n \tif (progress)\n \t\tfprintf(stderr, \"Total %u (delta %u), reused %u (delta %u)\\n\",\n-- \n1.5.1.89.g8abf0\n"}]}