push/fetch/clone --no-progress suppresses progress output

By default, progress output is disabled if stderr is not a terminal. The --progress option can be used to force progress output anyways. Conversely, --no-progress does not force progress output. In particular, if stderr is a terminal, progress output is enabled. This is unintuitive. Change --no-progress to force output off. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Clemens Buchacher committed Feb 13, 2012 at 21:17 UTC 01fdc21f6e90f56fc5a49cbba751d9ead19b2f03
7 files changed +28 -21
builtin/clone.c
+3 -3
@@ -45,7 +45,7 @@ static char *option_branch = NULL;
45 static const char *real_git_dir;
46 static char *option_upload_pack = "git-upload-pack";
47 static int option_verbosity;
48 -static int option_progress;
48 +static int option_progress = -1;
49 static struct string_list option_config;
50 static struct string_list option_reference;
51
@@ -60,8 +60,8 @@ static int opt_parse_reference(const struct option *opt, const char *arg, int un
60
61 static struct option builtin_clone_options[] = {
62 OPT__VERBOSITY(&option_verbosity),
63 - OPT_BOOLEAN(0, "progress", &option_progress,
64 - "force progress reporting"),
63 + OPT_BOOL(0, "progress", &option_progress,
64 + "force progress reporting"),
65 OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
66 "don't create a checkout"),
67 OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
builtin/fetch-pack.c
+1 -1
@@ -736,7 +736,7 @@ static int get_pack(int xd[2], char **pack_lockfile)
736 }
737 else {
738 *av++ = "unpack-objects";
739 - if (args.quiet)
739 + if (args.quiet || args.no_progress)
740 *av++ = "-q";
741 }
742 if (*hdr_arg)
builtin/fetch.c
+2 -2
@@ -30,7 +30,7 @@ enum {
30 };
31
32 static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
33 -static int progress, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
33 +static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
34 static int tags = TAGS_DEFAULT;
35 static const char *depth;
36 static const char *upload_pack;
@@ -78,7 +78,7 @@ static struct option builtin_fetch_options[] = {
78 OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
79 OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
80 "allow updating of HEAD ref"),
81 - OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
81 + OPT_BOOL(0, "progress", &progress, "force progress reporting"),
82 OPT_STRING(0, "depth", &depth, "depth",
83 "deepen history of shallow clone"),
84 { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",
builtin/push.c
+2 -2
@@ -19,7 +19,7 @@ static int thin;
19 static int deleterefs;
20 static const char *receivepack;
21 static int verbosity;
22 -static int progress;
22 +static int progress = -1;
23
24 static const char **refspec;
25 static int refspec_nr;
@@ -260,7 +260,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
260 OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
261 OPT_BIT('u', "set-upstream", &flags, "set upstream for git pull/status",
262 TRANSPORT_PUSH_SET_UPSTREAM),
263 - OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
263 + OPT_BOOL(0, "progress", &progress, "force progress reporting"),
264 OPT_END()
265 };
266
builtin/send-pack.c
+10 -8
@@ -58,7 +58,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
58 argv[i++] = "--thin";
59 if (args->use_ofs_delta)
60 argv[i++] = "--delta-base-offset";
61 - if (args->quiet)
61 + if (args->quiet || !args->progress)
62 argv[i++] = "-q";
63 if (args->progress)
64 argv[i++] = "--progress";
@@ -250,6 +250,7 @@ int send_pack(struct send_pack_args *args,
250 int allow_deleting_refs = 0;
251 int status_report = 0;
252 int use_sideband = 0;
253 + int quiet_supported = 0;
254 unsigned cmds_sent = 0;
255 int ret;
256 struct async demux;
@@ -263,8 +264,8 @@ int send_pack(struct send_pack_args *args,
264 args->use_ofs_delta = 1;
265 if (server_supports("side-band-64k"))
266 use_sideband = 1;
266 - if (!server_supports("quiet"))
267 - args->quiet = 0;
267 + if (server_supports("quiet"))
268 + quiet_supported = 1;
269
270 if (!remote_refs) {
271 fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
@@ -302,17 +303,18 @@ int send_pack(struct send_pack_args *args,
303 } else {
304 char *old_hex = sha1_to_hex(ref->old_sha1);
305 char *new_hex = sha1_to_hex(ref->new_sha1);
306 + int quiet = quiet_supported && (args->quiet || !args->progress);
307
308 if (!cmds_sent && (status_report || use_sideband || args->quiet)) {
309 packet_buf_write(&req_buf, "%s %s %s%c%s%s%s",
308 - old_hex, new_hex, ref->name, 0,
309 - status_report ? " report-status" : "",
310 - use_sideband ? " side-band-64k" : "",
311 - args->quiet ? " quiet" : "");
310 + old_hex, new_hex, ref->name, 0,
311 + status_report ? " report-status" : "",
312 + use_sideband ? " side-band-64k" : "",
313 + quiet ? " quiet" : "");
314 }
315 else
316 packet_buf_write(&req_buf, "%s %s %s",
315 - old_hex, new_hex, ref->name);
317 + old_hex, new_hex, ref->name);
318 ref->status = status_report ?
319 REF_STATUS_EXPECTING_REPORT :
320 REF_STATUS_OK;
t/t5523-push-upstream.sh
+2 -1
@@ -101,10 +101,11 @@ test_expect_success TTY 'push -q suppresses progress' '
101 ! grep "Writing objects" err
102 '
103
104 -test_expect_failure TTY 'push --no-progress suppresses progress' '
104 +test_expect_success TTY 'push --no-progress suppresses progress' '
105 ensure_fresh_upstream &&
106
107 test_terminal git push -u --no-progress upstream master >out 2>err &&
108 + ! grep "Unpacking objects" err &&
109 ! grep "Writing objects" err
110 '
111
transport.c
+8 -4
@@ -993,11 +993,15 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
993 * Rules used to determine whether to report progress (processing aborts
994 * when a rule is satisfied):
995 *
996 - * 1. Report progress, if force_progress is 1 (ie. --progress).
997 - * 2. Don't report progress, if verbosity < 0 (ie. -q/--quiet ).
998 - * 3. Report progress if isatty(2) is 1.
996 + * . Report progress, if force_progress is 1 (ie. --progress).
997 + * . Don't report progress, if force_progress is 0 (ie. --no-progress).
998 + * . Don't report progress, if verbosity < 0 (ie. -q/--quiet ).
999 + * . Report progress if isatty(2) is 1.
1000 **/
1000 - transport->progress = force_progress || (verbosity >= 0 && isatty(2));
1001 + if (force_progress >= 0)
1002 + transport->progress = !!force_progress;
1003 + else
1004 + transport->progress = verbosity >= 0 && isatty(2);
1005 }
1006
1007 int transport_push(struct transport *transport,