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

fast-import: Hide the pack boundary commits by default.

Most users don't need the pack boundary information that fast-import was printing to standard output, especially if they were calling it with --quiet. Those users who do want this information probably want it captured so they can go back and use it to repack the imported repository. So dumping the boundary commits to a log file makes more sense then printing them to standard output. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Feb 11, 2007 at 19:45 UTC bdf1c06dc17bdd6d54602544235aa3482ab67c9b
3 files changed +59 -11
Documentation/git-fast-import.txt
+9
@@ -64,6 +64,15 @@ OPTIONS
64 Frontends can use this file to validate imports after they
65 have been completed.
66
67 +--export-pack-edges=<file>::
68 + After creating a packfile, print a line of data to
69 + <file> listing the filename of the packfile and the last
70 + commit on each branch that was written to that packfile.
71 + This information may be useful after importing projects
72 + whose total object set exceeds the 4 GiB packfile limit,
73 + as these commits can be used as edge points during calls
74 + to gitlink:git-pack-objects[1].
75 +
76 --quiet::
77 Disable all non-fatal output, making fast-import silent when it
78 is successful. This option disables the output shown by
fast-import.c
+24 -11
@@ -261,6 +261,7 @@ static unsigned long object_count;
261 static unsigned long branch_count;
262 static unsigned long branch_load_count;
263 static int failure;
264 +static FILE *pack_edges;
265
266 /* Memory pools */
267 static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -811,18 +812,21 @@ static void end_packfile(void)
812 install_packed_git(new_p);
813
814 /* Print the boundary */
814 - fprintf(stdout, "%s:", new_p->pack_name);
815 - for (i = 0; i < branch_table_sz; i++) {
816 - for (b = branch_table[i]; b; b = b->table_next_branch) {
817 - if (b->pack_id == pack_id)
818 - fprintf(stdout, " %s", sha1_to_hex(b->sha1));
815 + if (pack_edges) {
816 + fprintf(pack_edges, "%s:", new_p->pack_name);
817 + for (i = 0; i < branch_table_sz; i++) {
818 + for (b = branch_table[i]; b; b = b->table_next_branch) {
819 + if (b->pack_id == pack_id)
820 + fprintf(pack_edges, " %s", sha1_to_hex(b->sha1));
821 + }
822 }
823 + for (t = first_tag; t; t = t->next_tag) {
824 + if (t->pack_id == pack_id)
825 + fprintf(pack_edges, " %s", sha1_to_hex(t->sha1));
826 + }
827 + fputc('\n', pack_edges);
828 + fflush(pack_edges);
829 }
821 - for (t = first_tag; t; t = t->next_tag) {
822 - if (t->pack_id == pack_id)
823 - fprintf(stdout, " %s", sha1_to_hex(t->sha1));
824 - }
825 - fputc('\n', stdout);
830
831 pack_id++;
832 }
@@ -1988,7 +1992,13 @@ int main(int argc, const char **argv)
1992 max_active_branches = strtoul(a + 18, NULL, 0);
1993 else if (!strncmp(a, "--export-marks=", 15))
1994 mark_file = a + 15;
1991 - else if (!strcmp(a, "--force"))
1995 + else if (!strncmp(a, "--export-pack-edges=", 20)) {
1996 + if (pack_edges)
1997 + fclose(pack_edges);
1998 + pack_edges = fopen(a + 20, "a");
1999 + if (!pack_edges)
2000 + die("Cannot open %s: %s", a + 20, strerror(errno));
2001 + } else if (!strcmp(a, "--force"))
2002 force_update = 1;
2003 else if (!strcmp(a, "--quiet"))
2004 show_stats = 0;
@@ -2033,6 +2043,9 @@ int main(int argc, const char **argv)
2043 unkeep_all_packs();
2044 dump_marks();
2045
2046 + if (pack_edges)
2047 + fclose(pack_edges);
2048 +
2049 if (show_stats) {
2050 uintmax_t total_count = 0, duplicate_count = 0;
2051 for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
t/t9300-fast-import.sh
+26
@@ -407,4 +407,30 @@ test_expect_success \
407 'git-cat-file blob H:h/e/l/lo >actual &&
408 diff -u expect actual'
409
410 +###
411 +### series I
412 +###
413 +
414 +cat >input <<INPUT_END
415 +commit refs/heads/export-boundary
416 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
417 +data <<COMMIT
418 +we have a border. its only 40 characters wide.
419 +COMMIT
420 +
421 +from refs/heads/branch
422 +
423 +INPUT_END
424 +test_expect_success \
425 + 'I: export-pack-edges' \
426 + 'git-fast-import --export-pack-edges=edges.list <input'
427 +
428 +cat >expect <<EOF
429 +.git/objects/pack/pack-.pack: `git-rev-parse --verify export-boundary`
430 +EOF
431 +test_expect_success \
432 + 'I: verify edge list' \
433 + 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
434 + diff -u expect actual'
435 +
436 test_done