Re: [PATCH] status: show progress bar if refreshing the index takes too long
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Sep 7, 2018, 20:29 UTC
- Message-ID
- <796edb6b-74ec-35dc-4bae-7a817f8fa9b5@gmail.com>
- In-Reply-To
- <CAPig+cQVCUyt5NvcSCAO63b1aO8HSc5AobCRKP5mp9jT_LYuJQ@mail.gmail.com>
On 9/7/2018 1:38 PM, Eric Sunshine wrote:
Show 17 quoted lines
> On Fri, Sep 7, 2018 at 11:51 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote: >> Refreshing the index is usually very fast, but it can still take a >> long time sometimes. Cold cache is one, or something else silly (*). >> In this case, it's good to show something to let the user know "git >> status" is not hanging, it's just busy doing something. >> >> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> >> --- >> diff --git a/read-cache.c b/read-cache.c >> @@ -1516,6 +1522,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, >> + if (progress) >> + display_progress(progress, i); >> @@ -1547,6 +1555,8 @@ int refresh_index(struct index_state *istate, unsigned int flags, >> + if (progress) >> + stop_progress(&progress); > Nit: Both display_progress() and stop_progress() behave sanely when > 'progress' is NULL, so no need for the conditional.
Don't forget this one in preload-index.c:preload_index():
+ if (pd.progress) + stop_progress(&pd.progress);
I found this extra one by creating the following rules in a Coccinelle script:
@@
expression e;
@@
- if (e) { stop_progress(&e); }
+ stop_progress(&e);@@
expression e;
expression i;
@@
- if (e) { display_progress(e, i); }
+ display_progress(e, i);Not sure if we want to put these in a .cocci script or not.
Thanks, -Stolee