diff options
author | ZheNing Hu <adlternative@gmail.com> | 2023-01-11 16:14:20 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-01-16 21:42:22 +0300 |
commit | 4433bd24e4acd015af9d05832c65bd6e3b097df2 (patch) | |
tree | e20d02671da522df057a3b5907edbff35bdb5294 /scalar.c | |
parent | c48035d29b4e524aed3a32f0403676f0d9128863 (diff) |
scalar: show progress if stderr refers to a terminal
Sometimes when users use scalar to download a monorepo with a long
commit history, they want to check the progress bar to know how long
they still need to wait during the fetch process, but scalar
suppresses this output by default.
So let's check whether scalar stderr refer to a terminal, if so,
show progress, otherwise disable it.
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'scalar.c')
-rw-r--r-- | scalar.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -404,7 +404,7 @@ void load_builtin_commands(const char *prefix, struct cmdnames *cmds) static int cmd_clone(int argc, const char **argv) { const char *branch = NULL; - int full_clone = 0, single_branch = 0; + int full_clone = 0, single_branch = 0, show_progress = isatty(2); struct option clone_options[] = { OPT_STRING('b', "branch", &branch, N_("<branch>"), N_("branch to checkout after clone")), @@ -499,7 +499,9 @@ static int cmd_clone(int argc, const char **argv) if (set_recommended_config(0)) return error(_("could not configure '%s'"), dir); - if ((res = run_git("fetch", "--quiet", "origin", NULL))) { + if ((res = run_git("fetch", "--quiet", + show_progress ? "--progress" : "--no-progress", + "origin", NULL))) { warning(_("partial clone failed; attempting full clone")); if (set_config("remote.origin.promisor") || @@ -508,7 +510,9 @@ static int cmd_clone(int argc, const char **argv) goto cleanup; } - if ((res = run_git("fetch", "--quiet", "origin", NULL))) + if ((res = run_git("fetch", "--quiet", + show_progress ? "--progress" : "--no-progress", + "origin", NULL))) goto cleanup; } |