Merge branch 'sg/overlong-progress-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:19 +0000 (16:41 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:19 +0000 (16:41 +0900)
Updating the display with progress message has been cleaned up to
deal better with overlong messages.

* sg/overlong-progress-fix:
  progress: break too long progress bar lines
  progress: clear previous progress update dynamically
  progress: assemble percentage and counters in a strbuf before printing
  progress: make display_progress() return void

1  2 
progress.c
progress.h

diff --cc progress.c
@@@ -34,9 -35,11 +35,12 @@@ struct progress 
        uint64_t total;
        unsigned last_percent;
        unsigned delay;
 +      unsigned sparse;
        struct throughput *throughput;
        uint64_t start_ns;
+       struct strbuf counters_sb;
+       int title_len;
+       int split;
  };
  
  static volatile sig_atomic_t progress_update;
@@@ -209,9 -236,11 +237,12 @@@ static struct progress *start_progress_
        progress->last_value = -1;
        progress->last_percent = -1;
        progress->delay = delay;
 +      progress->sparse = sparse;
        progress->throughput = NULL;
        progress->start_ns = getnanotime();
+       strbuf_init(&progress->counters_sb, 0);
+       progress->title_len = utf8_strwidth(title);
+       progress->split = 0;
        set_progress_signal();
        return progress;
  }
diff --cc progress.h
@@@ -4,12 -4,9 +4,12 @@@
  struct progress;
  
  void display_throughput(struct progress *progress, uint64_t total);
int display_progress(struct progress *progress, uint64_t n);
void display_progress(struct progress *progress, uint64_t n);
  struct progress *start_progress(const char *title, uint64_t total);
 +struct progress *start_sparse_progress(const char *title, uint64_t total);
  struct progress *start_delayed_progress(const char *title, uint64_t total);
 +struct progress *start_delayed_sparse_progress(const char *title,
 +                                             uint64_t total);
  void stop_progress(struct progress **progress);
  void stop_progress_msg(struct progress **progress, const char *msg);