Merge branch 'zh/scalar-progress'
"scalar" learned to give progress bar. * zh/scalar-progress: scalar: show progress if stderr refers to a terminal
This commit is contained in:
commit
ebed06a3e9
10
scalar.c
10
scalar.c
@ -405,7 +405,7 @@ void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
|
|||||||
static int cmd_clone(int argc, const char **argv)
|
static int cmd_clone(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
const char *branch = NULL;
|
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[] = {
|
struct option clone_options[] = {
|
||||||
OPT_STRING('b', "branch", &branch, N_("<branch>"),
|
OPT_STRING('b', "branch", &branch, N_("<branch>"),
|
||||||
N_("branch to checkout after clone")),
|
N_("branch to checkout after clone")),
|
||||||
@ -500,7 +500,9 @@ static int cmd_clone(int argc, const char **argv)
|
|||||||
if (set_recommended_config(0))
|
if (set_recommended_config(0))
|
||||||
return error(_("could not configure '%s'"), dir);
|
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"));
|
warning(_("partial clone failed; attempting full clone"));
|
||||||
|
|
||||||
if (set_config("remote.origin.promisor") ||
|
if (set_config("remote.origin.promisor") ||
|
||||||
@ -509,7 +511,9 @@ static int cmd_clone(int argc, const char **argv)
|
|||||||
goto cleanup;
|
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;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
test_description='test the `scalar clone` subcommand'
|
test_description='test the `scalar clone` subcommand'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
. "${TEST_DIRECTORY}/lib-terminal.sh"
|
||||||
|
|
||||||
GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
|
GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
|
||||||
export GIT_TEST_MAINT_SCHEDULER
|
export GIT_TEST_MAINT_SCHEDULER
|
||||||
@ -148,4 +149,29 @@ test_expect_success '--no-single-branch clones all branches' '
|
|||||||
cleanup_clone $enlistment
|
cleanup_clone $enlistment
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success TTY 'progress with tty' '
|
||||||
|
enlistment=progress1 &&
|
||||||
|
|
||||||
|
test_config -C to-clone uploadpack.allowfilter true &&
|
||||||
|
test_config -C to-clone uploadpack.allowanysha1inwant true &&
|
||||||
|
|
||||||
|
test_terminal env GIT_PROGRESS_DELAY=0 \
|
||||||
|
scalar clone "file://$(pwd)/to-clone" "$enlistment" 2>stderr &&
|
||||||
|
grep "Enumerating objects" stderr >actual &&
|
||||||
|
test_line_count = 2 actual &&
|
||||||
|
cleanup_clone $enlistment
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'progress without tty' '
|
||||||
|
enlistment=progress2 &&
|
||||||
|
|
||||||
|
test_config -C to-clone uploadpack.allowfilter true &&
|
||||||
|
test_config -C to-clone uploadpack.allowanysha1inwant true &&
|
||||||
|
|
||||||
|
GIT_PROGRESS_DELAY=0 scalar clone "file://$(pwd)/to-clone" "$enlistment" 2>stderr &&
|
||||||
|
! grep "Enumerating objects" stderr &&
|
||||||
|
! grep "Updating files" stderr &&
|
||||||
|
cleanup_clone $enlistment
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user