Teach fast-import how to sit quietly in the corner.

Often users will be running fast-import from within a larger frontend
process, and this may be a frequent periodic tool such as a future
edition of `git-svn fetch`.  We don't want to bombard users with our
large stats output if they won't be interested in it, so `--quiet`
is now an option to make gfi be more silent.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2007-02-07 02:19:31 -05:00
parent 825769a8fe
commit c499d76849
2 changed files with 48 additions and 32 deletions

View File

@ -64,6 +64,18 @@ OPTIONS
Frontends can use this file to validate imports after they Frontends can use this file to validate imports after they
have been completed. have been completed.
--quiet::
Disable all non-fatal output, making gfi silent when it
is successful. This option disables the output shown by
\--stats.
--stats::
Display some basic statistics about the objects gfi has
created, the packfiles they were stored into, and the
memory used by gfi during this run. Showing this output
is currently the default, but can be disabled with \--quiet.
Performance Performance
----------- -----------
The design of gfi allows it to import large projects in a minimum The design of gfi allows it to import large projects in a minimum
@ -106,8 +118,8 @@ fast-forward update, gfi will skip updating that ref and instead
prints a warning message. gfi will always attempt to update all prints a warning message. gfi will always attempt to update all
branch refs, and does not stop on the first failure. branch refs, and does not stop on the first failure.
Branch updates can be forced with `--force`, but its recommended that Branch updates can be forced with \--force, but its recommended that
this only be used on an otherwise quiet repository. Using `--force` this only be used on an otherwise quiet repository. Using \--force
is not necessary for an initial import into an empty repository. is not necessary for an initial import into an empty repository.
@ -148,11 +160,11 @@ Date Formats
~~~~~~~~~~~~ ~~~~~~~~~~~~
The following date formats are supported. A frontend should select The following date formats are supported. A frontend should select
the format it will use for this import by passing the format name the format it will use for this import by passing the format name
in the `--date-format=<fmt>` command line option. in the \--date-format=<fmt> command line option.
`raw`:: `raw`::
This is the Git native format and is `<time> SP <offutc>`. This is the Git native format and is `<time> SP <offutc>`.
It is also gfi's default format, if `--date-format` was It is also gfi's default format, if \--date-format was
not specified. not specified.
+ +
The time of the event is specified by `<time>` as the number of The time of the event is specified by `<time>` as the number of
@ -321,7 +333,7 @@ the email address from the other fields in the line. Note that
`LT` and `LF`. It is typically UTF-8 encoded. `LT` and `LF`. It is typically UTF-8 encoded.
The time of the change is specified by `<when>` using the date format The time of the change is specified by `<when>` using the date format
that was selected by the `--date-format=<fmt>` command line option. that was selected by the \--date-format=<fmt> command line option.
See ``Date Formats'' above for the set of supported formats, and See ``Date Formats'' above for the set of supported formats, and
their syntax. their syntax.
@ -735,7 +747,7 @@ branch, their in-memory storage size can grow to a considerable size
gfi automatically moves active branches to inactive status based on gfi automatically moves active branches to inactive status based on
a simple least-recently-used algorithm. The LRU chain is updated on a simple least-recently-used algorithm. The LRU chain is updated on
each `commit` command. The maximum number of active branches can be each `commit` command. The maximum number of active branches can be
increased or decreased on the command line with `--active-branches=`. increased or decreased on the command line with \--active-branches=.
per active tree per active tree
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~

View File

@ -1950,8 +1950,7 @@ static const char fast_import_usage[] =
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
int i; int i, show_stats = 1;
uintmax_t total_count, duplicate_count;
git_config(git_default_config); git_config(git_default_config);
@ -1981,6 +1980,10 @@ int main(int argc, const char **argv)
mark_file = a + 15; mark_file = a + 15;
else if (!strcmp(a, "--force")) else if (!strcmp(a, "--force"))
force_update = 1; force_update = 1;
else if (!strcmp(a, "--quiet"))
show_stats = 0;
else if (!strcmp(a, "--stats"))
show_stats = 1;
else else
die("unknown option %s", a); die("unknown option %s", a);
} }
@ -2020,10 +2023,10 @@ int main(int argc, const char **argv)
unkeep_all_packs(); unkeep_all_packs();
dump_marks(); dump_marks();
total_count = 0; if (show_stats) {
uintmax_t total_count = 0, duplicate_count = 0;
for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++) for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
total_count += object_count_by_type[i]; total_count += object_count_by_type[i];
duplicate_count = 0;
for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++) for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
duplicate_count += duplicate_count_by_type[i]; duplicate_count += duplicate_count_by_type[i];
@ -2045,6 +2048,7 @@ int main(int argc, const char **argv)
pack_report(); pack_report();
fprintf(stderr, "---------------------------------------------------------------------\n"); fprintf(stderr, "---------------------------------------------------------------------\n");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
}
return failure ? 1 : 0; return failure ? 1 : 0;
} }