@matheusbsbs / matheus-bagliano / commits / a6a1a831d9
Fork 0

Added option to export the marks table when fast-import terminates.

The marks table can be used by the frontend to load any commit after the import and compare it to whatever data the frontend knows about that commit. If the mark idnums can be easily correlated to some reference source then its relatively trivial to compare the GIT tree to the reference to verify the accuracy of the import. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Aug 25, 2006 at 16:03 UTC a6a1a831d9bdcdc0adb9a23ce450db08779c2871
1 file changed +35 -1
fast-import.c
+35 -1
@@ -223,6 +223,7 @@ static unsigned int object_entry_alloc = 1000;
223 static struct object_entry_pool *blocks;
224 static struct object_entry *object_table[1 << 16];
225 static struct mark_set *marks;
226 +static const char* mark_file;
227
228 /* Our last blob */
229 static struct last_object last_blob;
@@ -1122,6 +1123,36 @@ static void dump_tags()
1123 }
1124 }
1125
1126 +static void dump_marks_helper(FILE *f,
1127 + unsigned long base,
1128 + struct mark_set *m)
1129 +{
1130 + int k;
1131 + if (m->shift) {
1132 + for (k = 0; k < 1024; k++) {
1133 + if (m->data.sets[k])
1134 + dump_marks_helper(f, (base + k) << m->shift,
1135 + m->data.sets[k]);
1136 + }
1137 + } else {
1138 + for (k = 0; k < 1024; k++) {
1139 + if (m->data.marked[k])
1140 + fprintf(f, "%lu,%s\n", base + k,
1141 + sha1_to_hex(m->data.marked[k]->sha1));
1142 + }
1143 + }
1144 +}
1145 +
1146 +static void dump_marks()
1147 +{
1148 + if (mark_file)
1149 + {
1150 + FILE *f = fopen(mark_file, "w");
1151 + dump_marks_helper(f, 0, marks);
1152 + fclose(f);
1153 + }
1154 +}
1155 +
1156 static void read_next_command()
1157 {
1158 read_line(&command_buf, stdin, '\n');
@@ -1544,7 +1575,7 @@ static void cmd_new_tag()
1575 }
1576
1577 static const char fast_import_usage[] =
1547 -"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] temp.pack";
1578 +"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file] temp.pack";
1579
1580 int main(int argc, const char **argv)
1581 {
@@ -1569,6 +1600,8 @@ int main(int argc, const char **argv)
1600 max_depth = strtoul(a + 8, NULL, 0);
1601 else if (!strncmp(a, "--active-branches=", 18))
1602 max_active_branches = strtoul(a + 18, NULL, 0);
1603 + else if (!strncmp(a, "--export-marks=", 15))
1604 + mark_file = a + 15;
1605 else
1606 die("unknown option %s", a);
1607 }
@@ -1613,6 +1646,7 @@ int main(int argc, const char **argv)
1646 write_index(idx_name);
1647 dump_branches();
1648 dump_tags();
1649 + dump_marks();
1650
1651 fprintf(stderr, "%s statistics:\n", argv[0]);
1652 fprintf(stderr, "---------------------------------------------------\n");