From: Johannes Schindelin via GitGitGadget Date: Wed, 26 Jan 2022 08:41:47 GMT Subject: [PATCH 5/5] scalar diagnose: show a spinner while staging content Message-ID: <3a2cdce554a1755210592f3b9bb056d936ca98b6.1643186507.git.gitgitgadget@gmail.com> In-Reply-To: From: Johannes Schindelin It can take a while to gather all the information that `scalar diagnose` wants to accumulate. Typically this happens when the user is in need of quick solutions and therefore their patience is tested already. By showing a little spinner that spins around, we hope to help the user muster just a tiny bit more patience until `scalar diagnose` is done. Signed-off-by: Johannes Schindelin --- contrib/scalar/scalar.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/scalar/scalar.c b/contrib/scalar/scalar.c index c0ad4948215..224329f38f5 100644 --- a/contrib/scalar/scalar.c +++ b/contrib/scalar/scalar.c @@ -259,12 +259,26 @@ static int unregister_dir(void) return res; } +static void spinner(void) +{ + static const char whee[] = "|\010/\010-\010\\\010", *next = whee; + + if (!next) + return; + if (write(2, next, 2) < 0) + next = NULL; + else + next = next[2] ? next + 2 : whee; +} + static int stage(const char *git_dir, struct strbuf *buf, const char *path) { struct strbuf cacheinfo = STRBUF_INIT; struct child_process cp = CHILD_PROCESS_INIT; int res; + spinner(); + strbuf_addstr(&cacheinfo, "100644,"); cp.git_cmd = 1; -- gitgitgadget