@matheusbsbs / matheus-bagliano / commits / 2369ed7907
Fork 0

Print out the edge commits for each packfile in fast-import.

To help callers repack very large repositories into a series of packfiles fast-import now outputs the last commits/tags it wrote to a packfile when it prints out the packfile name. This information can be feed to pack-objects --revs to repack. For the first pack of an initial import this is pretty easy (just feed those SHA1s on stdin) but for subsequent packs you want to feed the subsequent pack's final SHA1s but also all prior pack's SHA1s prefixed with the negation operator. This way the prior pack's data does not get included into the subsequent pack. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 16, 2007 at 16:18 UTC 2369ed79071edf0f040eb2c280e1e2cf9a883bb9
1 file changed +24 -2
fast-import.c
+24 -2
@@ -193,6 +193,7 @@ struct branch
193 const char *name;
194 unsigned long last_commit;
195 struct tree_entry branch_tree;
196 + unsigned int pack_id;
197 unsigned char sha1[20];
198 };
199
@@ -200,6 +201,7 @@ struct tag
201 {
202 struct tag *next_tag;
203 const char *name;
204 + unsigned int pack_id;
205 unsigned char sha1[20];
206 };
207
@@ -733,7 +735,6 @@ static char* keep_pack(char *curr_index_name)
735 get_object_directory(), sha1_to_hex(pack_data->sha1));
736 if (move_temp_to_file(pack_data->pack_name, name))
737 die("cannot store pack file");
736 - printf("%s\n", name);
738
739 snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
740 get_object_directory(), sha1_to_hex(pack_data->sha1));
@@ -761,6 +762,9 @@ static void end_packfile()
762
763 if (object_count) {
764 char *idx_name;
765 + int i;
766 + struct branch *b;
767 + struct tag *t;
768
769 fixup_header_footer();
770 idx_name = keep_pack(create_index());
@@ -770,8 +774,24 @@ static void end_packfile()
774 if (!new_p)
775 die("core git rejected index %s", idx_name);
776 new_p->windows = old_p->windows;
773 - all_packs[pack_id++] = new_p;
777 + all_packs[pack_id] = new_p;
778 install_packed_git(new_p);
779 +
780 + /* Print the boundary */
781 + fprintf(stdout, "%s:", new_p->pack_name);
782 + for (i = 0; i < branch_table_sz; i++) {
783 + for (b = branch_table[i]; b; b = b->table_next_branch) {
784 + if (b->pack_id == pack_id)
785 + fprintf(stdout, " %s", sha1_to_hex(b->sha1));
786 + }
787 + }
788 + for (t = first_tag; t; t = t->next_tag) {
789 + if (t->pack_id == pack_id)
790 + fprintf(stdout, " %s", sha1_to_hex(t->sha1));
791 + }
792 + fputc('\n', stdout);
793 +
794 + pack_id++;
795 }
796 else
797 unlink(old_p->pack_name);
@@ -1679,6 +1699,7 @@ static void cmd_new_commit()
1699 new_data.buffer, sp - (char*)new_data.buffer,
1700 NULL, b->sha1, next_mark);
1701 b->last_commit = object_count_by_type[OBJ_COMMIT];
1702 + b->pack_id = pack_id;
1703
1704 if (branch_log) {
1705 int need_dq = quote_c_style(b->name, NULL, NULL, 0);
@@ -1787,6 +1808,7 @@ static void cmd_new_tag()
1808
1809 store_object(OBJ_TAG, new_data.buffer, sp - (char*)new_data.buffer,
1810 NULL, t->sha1, 0);
1811 + t->pack_id = pack_id;
1812
1813 if (branch_log) {
1814 int need_dq = quote_c_style(t->name, NULL, NULL, 0);