summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorTay Ray Chuan <rctay89@gmail.com>2010-02-24 20:50:26 +0800
committerJunio C Hamano <gitster@pobox.com>2010-02-24 08:35:44 -0800
commitd01b3c02e8a066054c308ee2ce521a2ea44738d3 (patch)
tree75fb151e00c082a805a3cd067b3cc89f11359e45 /transport.c
parent5bd631b3688e93ddedb33d4087deb91e2aae9e8e (diff)
downloadgit-d01b3c02e8a066054c308ee2ce521a2ea44738d3.tar.gz
transport->progress: use flag authoritatively
Set transport->progress in transport.c::transport_set_verbosity() after checking for the appropriate conditions (eg. --progress, isatty(2)), and thereafter use it without having to check again. The rules used are as follows (processing aborts when a rule is satisfied): 1. Report progress, if force_progress is 1 (ie. --progress). 2. Don't report progress, if verbosity < 0 (ie. -q/--quiet). 3. Report progress if isatty(2) is 1. This changes progress reporting behaviour such that if both --progress and --quiet are specified, progress is reported. In two areas, the logic to determine whether to *not* show progress is changed to simply use the negation of transport->progress. This changes behaviour in some ways (see previous paragraph for details). Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/transport.c b/transport.c
index 0655f65c1b..e2cfabd7ee 100644
--- a/transport.c
+++ b/transport.c
@@ -526,7 +526,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.include_tag = data->options.followtags;
args.verbose = (transport->verbose > 0);
args.quiet = (transport->verbose < 0);
- args.no_progress = args.quiet || (!transport->progress && !isatty(2));
+ args.no_progress = !transport->progress;
args.depth = data->options.depth;
for (i = 0; i < nr_heads; i++)
@@ -915,6 +915,8 @@ struct transport *transport_get(struct remote *remote, const char *url)
const char *helper;
struct transport *ret = xcalloc(1, sizeof(*ret));
+ ret->progress = isatty(2);
+
if (!remote)
die("No remote provided to transport_get()");
@@ -1013,12 +1015,23 @@ int transport_set_option(struct transport *transport,
return 1;
}
-void transport_set_verbosity(struct transport *transport, int verbosity)
+void transport_set_verbosity(struct transport *transport, int verbosity,
+ int force_progress)
{
if (verbosity >= 2)
transport->verbose = verbosity <= 3 ? verbosity : 3;
if (verbosity < 0)
transport->verbose = -1;
+
+ /**
+ * Rules used to determine whether to report progress (processing aborts
+ * when a rule is satisfied):
+ *
+ * 1. Report progress, if force_progress is 1 (ie. --progress).
+ * 2. Don't report progress, if verbosity < 0 (ie. -q/--quiet ).
+ * 3. Report progress if isatty(2) is 1.
+ **/
+ transport->progress = force_progress || (verbosity >= 0 && isatty(2));
}
int transport_push(struct transport *transport,