{"thread":{"id":"2098","subject":"[PATCH 2/3] Add support for \"local\" packing","startedAt":"2005-10-13T21:26:59Z","lastAt":"2005-10-13T21:26:59Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"10083","messageId":"Pine.LNX.4.64.0510131426390.23590@g5.osdl.org","threadId":"2098","inReplyTo":null,"subject":"[PATCH 2/3] Add support for \"local\" packing","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-10-13T21:26:59Z","receivedAt":"2005-10-13T21:26:59Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThis adds the \"--local\" flag to git-pack-objects, which acts like\n\"--incremental\", except that instead of ignoring all packed objects, it\nonly ignores objects that are packed and in an alternate object tree.\n\nAs a result, it effectively only does a local re-pack: any remote-packed\nobjects will stay in the alternate object directories.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/pack-objects.c b/pack-objects.c\nindex ef55cab..8a1ee74 100644\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -5,7 +5,7 @@\n #include \"pack.h\"\n #include \"csum-file.h\"\n \n-static const char pack_usage[] = \"git-pack-objects [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list\";\n+static const char pack_usage[] = \"git-pack-objects [--local] [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list\";\n \n struct object_entry {\n \tunsigned char sha1[20];\n@@ -20,6 +20,7 @@ struct object_entry {\n \n static unsigned char object_list_sha1[20];\n static int non_empty = 0;\n+static int local = 0;\n static int incremental = 0;\n static struct object_entry **sorted_by_sha, **sorted_by_type;\n static struct object_entry *objects = NULL;\n@@ -195,8 +196,20 @@ static int add_object_entry(unsigned cha\n \tunsigned int idx = nr_objects;\n \tstruct object_entry *entry;\n \n-\tif (incremental && has_sha1_pack(sha1))\n-\t\treturn 0;\n+\tif (incremental || local) {\n+\t\tstruct packed_git *p;\n+\n+\t\tfor (p = packed_git; p; p = p->next) {\n+\t\t\tstruct pack_entry e;\n+\n+\t\t\tif (find_pack_entry_one(sha1, &e, p)) {\n+\t\t\t\tif (incremental)\n+\t\t\t\t\treturn 0;\n+\t\t\t\tif (local && !p->pack_local)\n+\t\t\t\t\treturn 0;\n+\t\t\t}\n+\t\t}\n+\t}\n \n \tif (idx >= nr_alloc) {\n \t\tunsigned int needed = (idx + 1024) * 3 / 2;\n@@ -404,6 +417,10 @@ int main(int argc, char **argv)\n \t\t\t\tnon_empty = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(\"--local\", arg)) {\n+\t\t\t\tlocal = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(\"--incremental\", arg)) {\n \t\t\t\tincremental = 1;\n \t\t\t\tcontinue;\n@@ -436,6 +453,7 @@ int main(int argc, char **argv)\n \tif (pack_to_stdout != !base_name)\n \t\tusage(pack_usage);\n \n+\tprepare_packed_git();\n \twhile (fgets(line, sizeof(line), stdin) != NULL) {\n \t\tunsigned int hash;\n \t\tchar *p;\n"}]}