]> git.ipfire.org Git - thirdparty/git.git/blobdiff - progress.c
Merge branch 'bb/unicode-12.1-reiwa' into maint
[thirdparty/git.git] / progress.c
index 6cde5959fac75ab2640f11346dd124c962d98067..a2e8cf64a8d1aa2f94c745bbb5098b9c771f3a05 100644 (file)
@@ -128,7 +128,7 @@ static void display(struct progress *progress, uint64_t n, const char *done)
                                        (int) clear_len, eol);
                        } else if (!done && cols < progress_line_len) {
                                clear_len = progress->title_len + 1 < cols ?
-                                           cols - progress->title_len : 0;
+                                           cols - progress->title_len - 1 : 0;
                                fprintf(stderr, "%s:%*s\n  %s%s",
                                        progress->title, (int) clear_len, "",
                                        counters_sb->buf, eol);
@@ -167,12 +167,10 @@ void display_throughput(struct progress *progress, uint64_t total)
        now_ns = getnanotime();
 
        if (!tp) {
-               progress->throughput = tp = calloc(1, sizeof(*tp));
-               if (tp) {
-                       tp->prev_total = tp->curr_total = total;
-                       tp->prev_ns = now_ns;
-                       strbuf_init(&tp->display, 0);
-               }
+               progress->throughput = tp = xcalloc(1, sizeof(*tp));
+               tp->prev_total = tp->curr_total = total;
+               tp->prev_ns = now_ns;
+               strbuf_init(&tp->display, 0);
                return;
        }
        tp->curr_total = total;
@@ -225,13 +223,7 @@ void display_progress(struct progress *progress, uint64_t n)
 static struct progress *start_progress_delay(const char *title, uint64_t total,
                                             unsigned delay, unsigned sparse)
 {
-       struct progress *progress = malloc(sizeof(*progress));
-       if (!progress) {
-               /* unlikely, but here's a good fallback */
-               fprintf(stderr, "%s...\n", title);
-               fflush(stderr);
-               return NULL;
-       }
+       struct progress *progress = xmalloc(sizeof(*progress));
        progress->title = title;
        progress->total = total;
        progress->last_value = -1;