{"thread":{"id":"22052","subject":"[PATCH] git count-objects: handle packs bigger than 4G","startedAt":"2009-12-29T19:09:15Z","lastAt":"2009-12-29T19:09:15Z","messageCount":1,"participants":["Andreas Schwab"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"130475","messageId":"m2637pbns4.fsf@igel.home","threadId":"22052","inReplyTo":null,"subject":"[PATCH] git count-objects: handle packs bigger than 4G","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2009-12-29T19:09:15Z","receivedAt":"2009-12-29T19:09:15Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Use off_t to count sizes of packs and objects to avoid overflow after\n4Gb.\n\nSigned-off-by: Andreas Schwab <schwab@linux-m68k.org>\n---\n builtin-count-objects.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-count-objects.c b/builtin-count-objects.c\nindex 1b0b6c8..2bdd8eb 100644\n--- a/builtin-count-objects.c\n+++ b/builtin-count-objects.c\n@@ -11,7 +11,7 @@\n \n static void count_objects(DIR *d, char *path, int len, int verbose,\n \t\t\t  unsigned long *loose,\n-\t\t\t  unsigned long *loose_size,\n+\t\t\t  off_t *loose_size,\n \t\t\t  unsigned long *packed_loose,\n \t\t\t  unsigned long *garbage)\n {\n@@ -77,7 +77,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)\n \tint len = strlen(objdir);\n \tchar *path = xmalloc(len + 50);\n \tunsigned long loose = 0, packed = 0, packed_loose = 0, garbage = 0;\n-\tunsigned long loose_size = 0;\n+\toff_t loose_size = 0;\n \tstruct option opts[] = {\n \t\tOPT__VERBOSE(&verbose),\n \t\tOPT_END(),\n@@ -103,7 +103,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)\n \tif (verbose) {\n \t\tstruct packed_git *p;\n \t\tunsigned long num_pack = 0;\n-\t\tunsigned long size_pack = 0;\n+\t\toff_t size_pack = 0;\n \t\tif (!packed_git)\n \t\t\tprepare_packed_git();\n \t\tfor (p = packed_git; p; p = p->next) {\n@@ -116,15 +116,15 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)\n \t\t\tnum_pack++;\n \t\t}\n \t\tprintf(\"count: %lu\\n\", loose);\n-\t\tprintf(\"size: %lu\\n\", loose_size / 1024);\n+\t\tprintf(\"size: %lu\\n\", (unsigned long) (loose_size / 1024));\n \t\tprintf(\"in-pack: %lu\\n\", packed);\n \t\tprintf(\"packs: %lu\\n\", num_pack);\n-\t\tprintf(\"size-pack: %lu\\n\", size_pack / 1024);\n+\t\tprintf(\"size-pack: %lu\\n\", (unsigned long) (size_pack / 1024));\n \t\tprintf(\"prune-packable: %lu\\n\", packed_loose);\n \t\tprintf(\"garbage: %lu\\n\", garbage);\n \t}\n \telse\n \t\tprintf(\"%lu objects, %lu kilobytes\\n\",\n-\t\t       loose, loose_size / 1024);\n+\t\t       loose, (unsigned long) (loose_size / 1024));\n \treturn 0;\n }\n-- \n1.6.6\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}