{"thread":{"id":"7755","subject":"[PATCH] Don't repack existing objects in fast-import","startedAt":"2007-04-20T15:29:22Z","lastAt":"2007-04-20T15:29:22Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"39989","messageId":"20070420152922.GA17701@spearce.org","threadId":"7755","inReplyTo":null,"subject":"[PATCH] Don't repack existing objects in fast-import","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-04-20T15:29:22Z","receivedAt":"2007-04-20T15:29:22Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Some users of fast-import have been trying to use it to rewrite\ncommits and trees, an activity where the all of the relevant blobs\nare already available from the existing packfiles.  In such a case\nwe don't want to repack a blob, even if the frontend application\nhas supplied us the raw data rather than a mark or a SHA-1 name.\n\nI'm intentionally only checking the packfiles that existed when\nfast-import started and am always ignoring all loose object files.\n\nWe ignore loose objects because fast-import tends to operate on a\nvery large number of objects in a very short timespan, and it is\nusually creating new objects, not reusing existing ones.  In such\na situtation the majority of the objects will not be found in the\nexisting packfiles, nor will they be loose object files.  If the\nfrontend application really wants us to look at loose object files,\nthen they can just repack the repository before running fast-import.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n This is also now available in the master branch of my fastimport\n tree on repo.or.cz.\n\n fast-import.c |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex cdd629d..e3290df 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -904,6 +904,12 @@ static int store_object(\n \tif (e->offset) {\n \t\tduplicate_count_by_type[type]++;\n \t\treturn 1;\n+\t} else if (find_sha1_pack(sha1, packed_git)) {\n+\t\te->type = type;\n+\t\te->pack_id = MAX_PACK_ID;\n+\t\te->offset = 1; /* just not zero! */\n+\t\tduplicate_count_by_type[type]++;\n+\t\treturn 1;\n \t}\n \n \tif (last && last->data && last->depth < max_depth) {\n@@ -2021,6 +2027,7 @@ static void import_marks(const char *input_file)\n \t\t\te = insert_object(sha1);\n \t\t\te->type = type;\n \t\t\te->pack_id = MAX_PACK_ID;\n+\t\t\te->offset = 1; /* just not zero! */\n \t\t}\n \t\tinsert_mark(mark, e);\n \t}\n@@ -2086,6 +2093,7 @@ int main(int argc, const char **argv)\n \tif (i != argc)\n \t\tusage(fast_import_usage);\n \n+\tprepare_packed_git();\n \tstart_packfile();\n \tfor (;;) {\n \t\tread_next_command();\n-- \n1.5.1.1.135.gf948\n"}]}