]> git.ipfire.org Git - thirdparty/git.git/blobdiff - progress.c
fetch-pack: support more than one pack lockfile
[thirdparty/git.git] / progress.c
index 0063559aab6e233abd0a69aef6cead9d01e39948..6d2dcff0b6920037463f217d3d699305e8ccc491 100644 (file)
@@ -8,12 +8,14 @@
  * published by the Free Software Foundation.
  */
 
+#define GIT_TEST_PROGRESS_ONLY
 #include "cache.h"
 #include "gettext.h"
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
 #include "utf8.h"
+#include "config.h"
 
 #define TP_IDX_MAX      8
 
@@ -51,7 +53,6 @@ static volatile sig_atomic_t progress_update;
  */
 int progress_testing;
 uint64_t progress_test_ns = 0;
-void progress_test_force_update(void); /* To silence -Wmissing-prototypes */
 void progress_test_force_update(void)
 {
        progress_update = 1;
@@ -264,12 +265,23 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
        progress->title_len = utf8_strwidth(title);
        progress->split = 0;
        set_progress_signal();
+       trace2_region_enter("progress", title, the_repository);
        return progress;
 }
 
+static int get_default_delay(void)
+{
+       static int delay_in_secs = -1;
+
+       if (delay_in_secs < 0)
+               delay_in_secs = git_env_ulong("GIT_PROGRESS_DELAY", 2);
+
+       return delay_in_secs;
+}
+
 struct progress *start_delayed_progress(const char *title, uint64_t total)
 {
-       return start_progress_delay(title, total, 2, 0);
+       return start_progress_delay(title, total, get_default_delay(), 0);
 }
 
 struct progress *start_progress(const char *title, uint64_t total)
@@ -294,7 +306,7 @@ struct progress *start_sparse_progress(const char *title, uint64_t total)
 struct progress *start_delayed_sparse_progress(const char *title,
                                               uint64_t total)
 {
-       return start_progress_delay(title, total, 2, 1);
+       return start_progress_delay(title, total, get_default_delay(), 1);
 }
 
 static void finish_if_sparse(struct progress *progress)
@@ -309,6 +321,22 @@ void stop_progress(struct progress **p_progress)
 {
        finish_if_sparse(*p_progress);
 
+       if (p_progress && *p_progress) {
+               trace2_data_intmax("progress", the_repository, "total_objects",
+                                  (*p_progress)->total);
+
+               if ((*p_progress)->throughput)
+                       trace2_data_intmax("progress", the_repository,
+                                          "total_bytes",
+                                          (*p_progress)->throughput->curr_total);
+       }
+
+       trace2_region_leave("progress",
+                           p_progress && *p_progress
+                               ? (*p_progress)->title
+                               : NULL,
+                           the_repository);
+
        stop_progress_msg(p_progress, _("done"));
 }