diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2006-08-25 16:03:04 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-01-14 02:15:07 -0500 |
commit | a6a1a831d9bdcdc0adb9a23ce450db08779c2871 (patch) | |
tree | c3a69c9fb8d794895a5205d3080be243ed681ba7 /fast-import.c | |
parent | Account for tree entry memory costs in fast-import. (diff) | |
download | tgif-a6a1a831d9bdcdc0adb9a23ce450db08779c2871.tar.xz |
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>
Diffstat (limited to 'fast-import.c')
-rw-r--r-- | fast-import.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/fast-import.c b/fast-import.c index 311db4e6d5..d61da3adec 100644 --- a/fast-import.c +++ b/fast-import.c @@ -223,6 +223,7 @@ static unsigned int object_entry_alloc = 1000; static struct object_entry_pool *blocks; static struct object_entry *object_table[1 << 16]; static struct mark_set *marks; +static const char* mark_file; /* Our last blob */ static struct last_object last_blob; @@ -1122,6 +1123,36 @@ static void dump_tags() } } +static void dump_marks_helper(FILE *f, + unsigned long base, + struct mark_set *m) +{ + int k; + if (m->shift) { + for (k = 0; k < 1024; k++) { + if (m->data.sets[k]) + dump_marks_helper(f, (base + k) << m->shift, + m->data.sets[k]); + } + } else { + for (k = 0; k < 1024; k++) { + if (m->data.marked[k]) + fprintf(f, "%lu,%s\n", base + k, + sha1_to_hex(m->data.marked[k]->sha1)); + } + } +} + +static void dump_marks() +{ + if (mark_file) + { + FILE *f = fopen(mark_file, "w"); + dump_marks_helper(f, 0, marks); + fclose(f); + } +} + static void read_next_command() { read_line(&command_buf, stdin, '\n'); @@ -1544,7 +1575,7 @@ static void cmd_new_tag() } static const char fast_import_usage[] = -"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] temp.pack"; +"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file] temp.pack"; int main(int argc, const char **argv) { @@ -1569,6 +1600,8 @@ int main(int argc, const char **argv) max_depth = strtoul(a + 8, NULL, 0); else if (!strncmp(a, "--active-branches=", 18)) max_active_branches = strtoul(a + 18, NULL, 0); + else if (!strncmp(a, "--export-marks=", 15)) + mark_file = a + 15; else die("unknown option %s", a); } @@ -1613,6 +1646,7 @@ int main(int argc, const char **argv) write_index(idx_name); dump_branches(); dump_tags(); + dump_marks(); fprintf(stderr, "%s statistics:\n", argv[0]); fprintf(stderr, "---------------------------------------------------\n"); |