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

Correct object_count type and stat output in fast-import.

Since object_count is limited to 'unsigned long' (really an unsigned 32 bit integer value) by the pack file format we may as well use exactly that type here in fast-import for that counter. An earlier change by me incorrectly made it uintmax_t. But since object_count is a counter for the current packfile only, we don't want to output its value at the end. Instead we should sum up the individual type counters and report that total, as that will cover all of the packfiles. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 16, 2007 at 04:55 UTC a7ddc48765ff2e4f6601ea146cba4283a342e0b1
1 file changed +6 -3
fast-import.c
+6 -3
@@ -222,11 +222,11 @@ static uintmax_t max_objects = -1;
222
223 /* Stats and misc. counters */
224 static uintmax_t alloc_count;
225 -static uintmax_t object_count;
225 static uintmax_t marks_set_count;
226 static uintmax_t object_count_by_type[1 << TYPE_BITS];
227 static uintmax_t duplicate_count_by_type[1 << TYPE_BITS];
228 static uintmax_t delta_count_by_type[1 << TYPE_BITS];
229 +static unsigned long object_count;
230 static unsigned long branch_count;
231 static unsigned long branch_load_count;
232
@@ -1846,7 +1846,7 @@ int main(int argc, const char **argv)
1846 {
1847 int i;
1848 uintmax_t est_obj_cnt = object_entry_alloc;
1849 - uintmax_t duplicate_count;
1849 + uintmax_t total_count, duplicate_count;
1850
1851 setup_ident();
1852 git_config(git_default_config);
@@ -1914,6 +1914,9 @@ int main(int argc, const char **argv)
1914 if (branch_log)
1915 fclose(branch_log);
1916
1917 + total_count = 0;
1918 + for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
1919 + total_count += object_count_by_type[i];
1920 duplicate_count = 0;
1921 for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
1922 duplicate_count += duplicate_count_by_type[i];
@@ -1921,7 +1924,7 @@ int main(int argc, const char **argv)
1924 fprintf(stderr, "%s statistics:\n", argv[0]);
1925 fprintf(stderr, "---------------------------------------------------------------------\n");
1926 fprintf(stderr, "Alloc'd objects: %10ju (%10ju overflow )\n", alloc_count, alloc_count - est_obj_cnt);
1924 - fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", object_count, duplicate_count);
1927 + fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", total_count, duplicate_count);
1928 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]);
1929 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]);
1930 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]);