From 486a3d716427ac81594fe63d4e9cae64703dbc56 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Sat, 26 Dec 2009 01:12:03 +0800 Subject: check stderr with isatty() instead of stdout when deciding to show progress Make transport code (viz. transport.c::fetch_refs_via_pack() and transport-helper.c::standard_options()) that decides to show progress check if stderr is a terminal, instead of stdout. After all, progress reports (via the API in progress.[ch]) are sent to stderr. Update the documentation for git-clone to say "standard error" as well. Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- Documentation/git-clone.txt | 2 +- transport-helper.c | 2 +- transport.c | 2 +- transport.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 7ccd742a8..f298fdd4c 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -101,7 +101,7 @@ objects from the source repository into a pack in the cloned repository. --verbose:: -v:: - Display the progress bar, even in case the standard output is not + Display the progress bar, even in case the standard error is not a terminal. --no-checkout:: diff --git a/transport-helper.c b/transport-helper.c index 5078c7100..bfe3bc30a 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -144,7 +144,7 @@ static void standard_options(struct transport *t) char buf[16]; int n; int v = t->verbose; - int no_progress = v < 0 || (!t->progress && !isatty(1)); + int no_progress = v < 0 || (!t->progress && !isatty(2)); set_helper_option(t, "progress", !no_progress ? "true" : "false"); diff --git a/transport.c b/transport.c index 7362ec09b..31c88f33a 100644 --- a/transport.c +++ b/transport.c @@ -476,7 +476,7 @@ static int fetch_refs_via_pack(struct transport *transport, args.include_tag = data->followtags; args.verbose = (transport->verbose > 0); args.quiet = (transport->verbose < 0); - args.no_progress = args.quiet || (!transport->progress && !isatty(1)); + args.no_progress = args.quiet || (!transport->progress && !isatty(2)); args.depth = data->depth; for (i = 0; i < nr_heads; i++) diff --git a/transport.h b/transport.h index e4e6177e2..98bb623c4 100644 --- a/transport.h +++ b/transport.h @@ -26,7 +26,7 @@ struct transport { int (*disconnect)(struct transport *connection); char *pack_lockfile; signed verbose : 3; - /* Force progress even if the output is not a tty */ + /* Force progress even if stderr is not a tty */ unsigned progress : 1; }; -- cgit v1.2.1 From 488c316334bd9e4e75d4852a50b834298b8cf64d Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Sat, 26 Dec 2009 01:12:04 +0800 Subject: git-clone.txt: reword description of progress behaviour Mention progress reporting behaviour in the descriptions for -q/ --quiet and -v/--verbose options, in the style of git-pack-objects.txt. Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- Documentation/git-clone.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index f298fdd4c..e722e6cfd 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -96,13 +96,16 @@ objects from the source repository into a pack in the cloned repository. --quiet:: -q:: - Operate quietly. This flag is also passed to the `rsync' + Operate quietly. Progress is not reported to the standard + error stream. This flag is also passed to the `rsync' command when given. --verbose:: -v:: - Display the progress bar, even in case the standard error is not - a terminal. + Progress status is reported on the standard error stream + by default when it is attached to a terminal, unless -q + is specified. This flag forces progress status even if the + standard error stream is not directed to a terminal. --no-checkout:: -n:: -- cgit v1.2.1 From 65273bfb9b6991138d298527d971e82e28fe678e Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Sat, 26 Dec 2009 01:12:05 +0800 Subject: clone: set transport->verbose when -v/--verbose is used Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- builtin-clone.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin-clone.c b/builtin-clone.c index caf302503..2d8bf5120 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -524,8 +524,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (option_quiet) transport->verbose = -1; - else if (option_verbose) + else if (option_verbose) { + transport->verbose = 1; transport->progress = 1; + } if (option_upload_pack) transport_set_option(transport, TRANS_OPT_UPLOADPACK, -- cgit v1.2.1 From 5a518ad4679c91f0d0afd38fcc3cbf04e8699c46 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Sat, 26 Dec 2009 01:12:06 +0800 Subject: clone: use --progress to force progress reporting Follow the argument convention of git-pack-objects, such that a separate option (--preogress) is used to force progress reporting instead of -v/--verbose. -v/--verbose now does not force progress reporting. Make git-clone.txt say so. This should cover all the bases in 21188b1 (Implement git clone -v), which implemented the option to force progress reporting. Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- Documentation/git-clone.txt | 3 +++ builtin-clone.c | 8 ++++++-- t/t5702-clone-options.sh | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index e722e6cfd..f43c8b2c0 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -102,6 +102,9 @@ objects from the source repository into a pack in the cloned repository. --verbose:: -v:: + Run verbosely. + +--progress:: Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the diff --git a/builtin-clone.c b/builtin-clone.c index 2d8bf5120..8ad2bd469 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -44,10 +44,13 @@ static char *option_origin = NULL; static char *option_branch = NULL; static char *option_upload_pack = "git-upload-pack"; static int option_verbose; +static int option_progress; static struct option builtin_clone_options[] = { OPT__QUIET(&option_quiet), OPT__VERBOSE(&option_verbose), + OPT_BOOLEAN(0, "progress", &option_progress, + "force progress reporting"), OPT_BOOLEAN('n', "no-checkout", &option_no_checkout, "don't create a checkout"), OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"), @@ -524,10 +527,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (option_quiet) transport->verbose = -1; - else if (option_verbose) { + else if (option_verbose) transport->verbose = 1; + + if (option_progress) transport->progress = 1; - } if (option_upload_pack) transport_set_option(transport, TRANS_OPT_UPLOADPACK, diff --git a/t/t5702-clone-options.sh b/t/t5702-clone-options.sh index 27825f5f3..02cb02472 100755 --- a/t/t5702-clone-options.sh +++ b/t/t5702-clone-options.sh @@ -27,7 +27,8 @@ test_expect_success 'redirected clone' ' ' test_expect_success 'redirected clone -v' ' - git clone -v "file://$(pwd)/parent" clone-redirected-v >out 2>err && + git clone --progress "file://$(pwd)/parent" clone-redirected-progress \ + >out 2>err && test -s err ' -- cgit v1.2.1