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>
Shawn O. Pearce committed
Feb 7, 2007 at 02:19 UTC
c499d76849b09194434708376138952e2cac2e68
2 files changed
+49
-33
Documentation/git-fast-import.txt
+18
-6
@@ -64,6 +64,18 @@ OPTIONS
64
Frontends can use this file to validate imports after they
65
have been completed.
66
67
+--quiet::
68
+ Disable all non-fatal output, making gfi silent when it
69
+ is successful. This option disables the output shown by
70
+ \--stats.
71
+
72
+--stats::
73
+ Display some basic statistics about the objects gfi has
74
+ created, the packfiles they were stored into, and the
75
+ memory used by gfi during this run. Showing this output
76
+ is currently the default, but can be disabled with \--quiet.
77
+
78
+
79
Performance
80
-----------
81
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
118
prints a warning message. gfi will always attempt to update all
119
branch refs, and does not stop on the first failure.
120
109
-Branch updates can be forced with `--force`, but its recommended that
110
-this only be used on an otherwise quiet repository. Using `--force`
121
+Branch updates can be forced with \--force, but its recommended that
122
+this only be used on an otherwise quiet repository. Using \--force
123
is not necessary for an initial import into an empty repository.
124
125
@@ -148,11 +160,11 @@ Date Formats
160
~~~~~~~~~~~~
161
The following date formats are supported. A frontend should select
162
the format it will use for this import by passing the format name
151
-in the `--date-format=<fmt>` command line option.
163
+in the \--date-format=<fmt> command line option.
164
165
`raw`::
166
This is the Git native format and is `<time> SP <offutc>`.
155
- It is also gfi's default format, if `--date-format` was
167
+ It is also gfi's default format, if \--date-format was
168
not specified.
169
+
170
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
333
`LT` and `LF`. It is typically UTF-8 encoded.
334
335
The time of the change is specified by `<when>` using the date format
324
-that was selected by the `--date-format=<fmt>` command line option.
336
+that was selected by the \--date-format=<fmt> command line option.
337
See ``Date Formats'' above for the set of supported formats, and
338
their syntax.
339
@@ -735,7 +747,7 @@ branch, their in-memory storage size can grow to a considerable size
747
gfi automatically moves active branches to inactive status based on
748
a simple least-recently-used algorithm. The LRU chain is updated on
749
each `commit` command. The maximum number of active branches can be
738
-increased or decreased on the command line with `--active-branches=`.
750
+increased or decreased on the command line with \--active-branches=.
751
752
per active tree
753
~~~~~~~~~~~~~~~
fast-import.c
+31
-27
@@ -1950,8 +1950,7 @@ static const char fast_import_usage[] =
1950
1951
int main(int argc, const char **argv)
1952
{
1953
- int i;
1954
- uintmax_t total_count, duplicate_count;
1953
+ int i, show_stats = 1;
1954
1955
git_config(git_default_config);
1956
@@ -1981,6 +1980,10 @@ int main(int argc, const char **argv)
1980
mark_file = a + 15;
1981
else if (!strcmp(a, "--force"))
1982
force_update = 1;
1983
+ else if (!strcmp(a, "--quiet"))
1984
+ show_stats = 0;
1985
+ else if (!strcmp(a, "--stats"))
1986
+ show_stats = 1;
1987
else
1988
die("unknown option %s", a);
1989
}
@@ -2020,31 +2023,32 @@ int main(int argc, const char **argv)
2023
unkeep_all_packs();
2024
dump_marks();
2025
2023
- total_count = 0;
2024
- for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
2025
- total_count += object_count_by_type[i];
2026
- duplicate_count = 0;
2027
- for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
2028
- duplicate_count += duplicate_count_by_type[i];
2029
-
2030
- fprintf(stderr, "%s statistics:\n", argv[0]);
2031
- fprintf(stderr, "---------------------------------------------------------------------\n");
2032
- fprintf(stderr, "Alloc'd objects: %10ju\n", alloc_count);
2033
- fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", total_count, duplicate_count);
2034
- fprintf(stderr, " blobs : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
2035
- fprintf(stderr, " trees : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);
2036
- fprintf(stderr, " commits: %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_COMMIT], duplicate_count_by_type[OBJ_COMMIT], delta_count_by_type[OBJ_COMMIT]);
2037
- fprintf(stderr, " tags : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TAG], duplicate_count_by_type[OBJ_TAG], delta_count_by_type[OBJ_TAG]);
2038
- fprintf(stderr, "Total branches: %10lu (%10lu loads )\n", branch_count, branch_load_count);
2039
- fprintf(stderr, " marks: %10ju (%10ju unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
2040
- fprintf(stderr, " atoms: %10u\n", atom_cnt);
2041
- fprintf(stderr, "Memory total: %10ju KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
2042
- fprintf(stderr, " pools: %10lu KiB\n", total_allocd/1024);
2043
- fprintf(stderr, " objects: %10ju KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
2044
- fprintf(stderr, "---------------------------------------------------------------------\n");
2045
- pack_report();
2046
- fprintf(stderr, "---------------------------------------------------------------------\n");
2047
- fprintf(stderr, "\n");
2026
+ if (show_stats) {
2027
+ uintmax_t total_count = 0, duplicate_count = 0;
2028
+ for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
2029
+ total_count += object_count_by_type[i];
2030
+ for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
2031
+ duplicate_count += duplicate_count_by_type[i];
2032
+
2033
+ fprintf(stderr, "%s statistics:\n", argv[0]);
2034
+ fprintf(stderr, "---------------------------------------------------------------------\n");
2035
+ fprintf(stderr, "Alloc'd objects: %10ju\n", alloc_count);
2036
+ fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", total_count, duplicate_count);
2037
+ fprintf(stderr, " blobs : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
2038
+ fprintf(stderr, " trees : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);
2039
+ fprintf(stderr, " commits: %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_COMMIT], duplicate_count_by_type[OBJ_COMMIT], delta_count_by_type[OBJ_COMMIT]);
2040
+ fprintf(stderr, " tags : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TAG], duplicate_count_by_type[OBJ_TAG], delta_count_by_type[OBJ_TAG]);
2041
+ fprintf(stderr, "Total branches: %10lu (%10lu loads )\n", branch_count, branch_load_count);
2042
+ fprintf(stderr, " marks: %10ju (%10ju unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
2043
+ fprintf(stderr, " atoms: %10u\n", atom_cnt);
2044
+ fprintf(stderr, "Memory total: %10ju KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
2045
+ fprintf(stderr, " pools: %10lu KiB\n", total_allocd/1024);
2046
+ fprintf(stderr, " objects: %10ju KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
2047
+ fprintf(stderr, "---------------------------------------------------------------------\n");
2048
+ pack_report();
2049
+ fprintf(stderr, "---------------------------------------------------------------------\n");
2050
+ fprintf(stderr, "\n");
2051
+ }
2052
2053
return failure ? 1 : 0;
2054
}