Merge branch 'nd/status-refresh-progress'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:03 +0000 (13:34 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:03 +0000 (13:34 +0900)
"git status" learns to show progress bar when refreshing the index
takes a long time.

* nd/status-refresh-progress:
status: show progress bar if refreshing the index takes too long

1  2 
builtin/am.c
builtin/commit.c
cache.h
preload-index.c
read-cache.c
sequencer.c
diff --cc builtin/am.c
Simple merge
Simple merge
diff --cc cache.h
Simple merge
diff --cc preload-index.c
index 16dc5ad868ff0d69a49a30d9130779997267c63b,2541b307e8bafc7280c0ded43346a0d723af1768..9e7152ab14d9359d0a48da8b25cd58253a13fc0c
@@@ -5,7 -5,7 +5,8 @@@
  #include "pathspec.h"
  #include "dir.h"
  #include "fsmonitor.h"
 +#include "config.h"
+ #include "progress.h"
  
  #ifdef NO_PTHREADS
  static void preload_index(struct index_state *index,
@@@ -79,6 -105,8 +106,7 @@@ static void preload_index(struct index_
  {
        int threads, i, work, offset;
        struct thread_data data[MAX_PARALLEL];
 -      uint64_t start = getnanotime();
+       struct progress_data pd;
  
        if (!core_preload_index)
                return;
                if (pthread_join(p->pthread, NULL))
                        die("unable to join threaded lstat");
        }
 -      trace_performance_since(start, "preload index");
+       stop_progress(&pd.progress);
 +      trace_performance_leave("preload index");
  }
  #endif
  
diff --cc read-cache.c
index 4c994e4b65cc820351117ccc90647d4534cde415,5969ca93c7e5d933aba0e882a0299b29419a2990..1df5c16dbc31d444b98478bc892821bf1e2dda85
@@@ -23,7 -23,7 +23,8 @@@
  #include "split-index.h"
  #include "utf8.h"
  #include "fsmonitor.h"
 +#include "thread-utils.h"
+ #include "progress.h"
  
  /* Mask for the name length in ce_flags in the on-disk index */
  
@@@ -1483,8 -1477,13 +1484,13 @@@ int refresh_index(struct index_state *i
        const char *typechange_fmt;
        const char *added_fmt;
        const char *unmerged_fmt;
 -      uint64_t start = getnanotime();
+       struct progress *progress = NULL;
+       if (flags & REFRESH_PROGRESS && isatty(2))
+               progress = start_delayed_progress(_("Refresh index"),
+                                                 istate->cache_nr);
  
 +      trace_performance_enter();
        modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
        deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
        typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
  
                replace_index_entry(istate, i, new_entry);
        }
 -      trace_performance_since(start, "refresh index");
+       if (progress) {
+               display_progress(progress, istate->cache_nr);
+               stop_progress(&progress);
+       }
 +      trace_performance_leave("refresh index");
        return has_errors;
  }
  
diff --cc sequencer.c
Simple merge