summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5bd631b)
raw | patch | inline | side by side (parent: 5bd631b)
author | Tay Ray Chuan <rctay89@gmail.com> | |
Wed, 24 Feb 2010 12:50:26 +0000 (20:50 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 24 Feb 2010 16:35:44 +0000 (08:35 -0800) |
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>
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>
builtin-clone.c | patch | blob | history | |
builtin-fetch.c | patch | blob | history | |
builtin-push.c | patch | blob | history | |
transport-helper.c | patch | blob | history | |
transport.c | patch | blob | history | |
transport.h | patch | blob | history |
diff --git a/builtin-clone.c b/builtin-clone.c
index 959fe4b59e61b06c4d3aa73ce35666b036b5cd7e..05f8fb4771b1ef07030338a6fd38dc7cb3bc1d1d 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
transport_set_option(transport, TRANS_OPT_DEPTH,
option_depth);
- transport_set_verbosity(transport, option_verbosity);
-
- if (option_progress)
- transport->progress = 1;
+ transport_set_verbosity(transport, option_verbosity, option_progress);
if (option_upload_pack)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
diff --git a/builtin-fetch.c b/builtin-fetch.c
index d23ea2a53e89b03418067d553a7c9e98ea2ed050..6b96b41382c450914ca69a2d660eb3e07b190ed4 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
die("Where do you want to fetch from today?");
transport = transport_get(remote, NULL);
- transport_set_verbosity(transport, verbosity);
+ transport_set_verbosity(transport, verbosity, 0);
if (upload_pack)
set_option(TRANS_OPT_UPLOADPACK, upload_pack);
if (keep)
diff --git a/builtin-push.c b/builtin-push.c
index 0082dadb73fb0767dd1e69001e485a2cbca6bf13..dce3152fec7b73821fa1a27cd841c7bd973d966c 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
int err;
int nonfastforward;
- transport_set_verbosity(transport, verbosity);
+ transport_set_verbosity(transport, verbosity, 0);
if (receivepack)
transport_set_option(transport,
diff --git a/transport-helper.c b/transport-helper.c
index 3d33697a4b2ee881dcd2ed7237bc2945b859e04d..3e69ebd188b4fd419d7aef000792762b76fab708 100644 (file)
--- a/transport-helper.c
+++ b/transport-helper.c
char buf[16];
int n;
int v = t->verbose;
- int no_progress = v < 0 || (!t->progress && !isatty(2));
- set_helper_option(t, "progress", !no_progress ? "true" : "false");
+ set_helper_option(t, "progress", t->progress ? "true" : "false");
n = snprintf(buf, sizeof(buf), "%d", v + 1);
if (n >= sizeof(buf))
diff --git a/transport.c b/transport.c
index 0655f65c1b530127f6a044f5102ffa58b2d32d20..e2cfabd7eeda2a6953b2785385f383f998525ca3 100644 (file)
--- a/transport.c
+++ b/transport.c
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++)
const char *helper;
struct transport *ret = xcalloc(1, sizeof(*ret));
+ ret->progress = isatty(2);
+
if (!remote)
die("No remote provided to transport_get()");
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,
diff --git a/transport.h b/transport.h
index c0743b1086edef60452d98711e52ad2240c79680..de2745a6edded782831b08d2f882f759f73d29f5 100644 (file)
--- a/transport.h
+++ b/transport.h
int (*disconnect)(struct transport *connection);
char *pack_lockfile;
signed verbose : 3;
- /* Force progress even if stderr is not a tty */
+ /**
+ * Transports should not set this directly, and should use this
+ * value without having to check isatty(2), -q/--quiet
+ * (transport->verbose < 0), etc. - checking has already been done
+ * in transport_set_verbosity().
+ **/
unsigned progress : 1;
/*
* If transport is at least potentially smart, this points to
**/
int transport_set_option(struct transport *transport, const char *name,
const char *value);
-void transport_set_verbosity(struct transport *transport, int verbosity);
+void transport_set_verbosity(struct transport *transport, int verbosity,
+ int force_progress);
int transport_push(struct transport *connection,
int refspec_nr, const char **refspec, int flags,