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>
This commit is contained in:
parent
58d4203aa6
commit
01fdc21f6e
@ -45,7 +45,7 @@ static char *option_branch = NULL;
|
|||||||
static const char *real_git_dir;
|
static const char *real_git_dir;
|
||||||
static char *option_upload_pack = "git-upload-pack";
|
static char *option_upload_pack = "git-upload-pack";
|
||||||
static int option_verbosity;
|
static int option_verbosity;
|
||||||
static int option_progress;
|
static int option_progress = -1;
|
||||||
static struct string_list option_config;
|
static struct string_list option_config;
|
||||||
static struct string_list option_reference;
|
static struct string_list option_reference;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ static int opt_parse_reference(const struct option *opt, const char *arg, int un
|
|||||||
|
|
||||||
static struct option builtin_clone_options[] = {
|
static struct option builtin_clone_options[] = {
|
||||||
OPT__VERBOSITY(&option_verbosity),
|
OPT__VERBOSITY(&option_verbosity),
|
||||||
OPT_BOOLEAN(0, "progress", &option_progress,
|
OPT_BOOL(0, "progress", &option_progress,
|
||||||
"force progress reporting"),
|
"force progress reporting"),
|
||||||
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
|
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
|
||||||
"don't create a checkout"),
|
"don't create a checkout"),
|
||||||
|
@ -736,7 +736,7 @@ static int get_pack(int xd[2], char **pack_lockfile)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*av++ = "unpack-objects";
|
*av++ = "unpack-objects";
|
||||||
if (args.quiet)
|
if (args.quiet || args.no_progress)
|
||||||
*av++ = "-q";
|
*av++ = "-q";
|
||||||
}
|
}
|
||||||
if (*hdr_arg)
|
if (*hdr_arg)
|
||||||
|
@ -30,7 +30,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
|
static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
|
||||||
static int progress, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
|
static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
|
||||||
static int tags = TAGS_DEFAULT;
|
static int tags = TAGS_DEFAULT;
|
||||||
static const char *depth;
|
static const char *depth;
|
||||||
static const char *upload_pack;
|
static const char *upload_pack;
|
||||||
@ -78,7 +78,7 @@ static struct option builtin_fetch_options[] = {
|
|||||||
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
|
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
|
||||||
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
|
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
|
||||||
"allow updating of HEAD ref"),
|
"allow updating of HEAD ref"),
|
||||||
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
|
OPT_BOOL(0, "progress", &progress, "force progress reporting"),
|
||||||
OPT_STRING(0, "depth", &depth, "depth",
|
OPT_STRING(0, "depth", &depth, "depth",
|
||||||
"deepen history of shallow clone"),
|
"deepen history of shallow clone"),
|
||||||
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",
|
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",
|
||||||
|
@ -19,7 +19,7 @@ static int thin;
|
|||||||
static int deleterefs;
|
static int deleterefs;
|
||||||
static const char *receivepack;
|
static const char *receivepack;
|
||||||
static int verbosity;
|
static int verbosity;
|
||||||
static int progress;
|
static int progress = -1;
|
||||||
|
|
||||||
static const char **refspec;
|
static const char **refspec;
|
||||||
static int refspec_nr;
|
static int refspec_nr;
|
||||||
@ -260,7 +260,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
|
|||||||
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
|
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
|
||||||
OPT_BIT('u', "set-upstream", &flags, "set upstream for git pull/status",
|
OPT_BIT('u', "set-upstream", &flags, "set upstream for git pull/status",
|
||||||
TRANSPORT_PUSH_SET_UPSTREAM),
|
TRANSPORT_PUSH_SET_UPSTREAM),
|
||||||
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
|
OPT_BOOL(0, "progress", &progress, "force progress reporting"),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
|
|||||||
argv[i++] = "--thin";
|
argv[i++] = "--thin";
|
||||||
if (args->use_ofs_delta)
|
if (args->use_ofs_delta)
|
||||||
argv[i++] = "--delta-base-offset";
|
argv[i++] = "--delta-base-offset";
|
||||||
if (args->quiet)
|
if (args->quiet || !args->progress)
|
||||||
argv[i++] = "-q";
|
argv[i++] = "-q";
|
||||||
if (args->progress)
|
if (args->progress)
|
||||||
argv[i++] = "--progress";
|
argv[i++] = "--progress";
|
||||||
@ -250,6 +250,7 @@ int send_pack(struct send_pack_args *args,
|
|||||||
int allow_deleting_refs = 0;
|
int allow_deleting_refs = 0;
|
||||||
int status_report = 0;
|
int status_report = 0;
|
||||||
int use_sideband = 0;
|
int use_sideband = 0;
|
||||||
|
int quiet_supported = 0;
|
||||||
unsigned cmds_sent = 0;
|
unsigned cmds_sent = 0;
|
||||||
int ret;
|
int ret;
|
||||||
struct async demux;
|
struct async demux;
|
||||||
@ -263,8 +264,8 @@ int send_pack(struct send_pack_args *args,
|
|||||||
args->use_ofs_delta = 1;
|
args->use_ofs_delta = 1;
|
||||||
if (server_supports("side-band-64k"))
|
if (server_supports("side-band-64k"))
|
||||||
use_sideband = 1;
|
use_sideband = 1;
|
||||||
if (!server_supports("quiet"))
|
if (server_supports("quiet"))
|
||||||
args->quiet = 0;
|
quiet_supported = 1;
|
||||||
|
|
||||||
if (!remote_refs) {
|
if (!remote_refs) {
|
||||||
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
|
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
|
||||||
@ -302,13 +303,14 @@ int send_pack(struct send_pack_args *args,
|
|||||||
} else {
|
} else {
|
||||||
char *old_hex = sha1_to_hex(ref->old_sha1);
|
char *old_hex = sha1_to_hex(ref->old_sha1);
|
||||||
char *new_hex = sha1_to_hex(ref->new_sha1);
|
char *new_hex = sha1_to_hex(ref->new_sha1);
|
||||||
|
int quiet = quiet_supported && (args->quiet || !args->progress);
|
||||||
|
|
||||||
if (!cmds_sent && (status_report || use_sideband || args->quiet)) {
|
if (!cmds_sent && (status_report || use_sideband || args->quiet)) {
|
||||||
packet_buf_write(&req_buf, "%s %s %s%c%s%s%s",
|
packet_buf_write(&req_buf, "%s %s %s%c%s%s%s",
|
||||||
old_hex, new_hex, ref->name, 0,
|
old_hex, new_hex, ref->name, 0,
|
||||||
status_report ? " report-status" : "",
|
status_report ? " report-status" : "",
|
||||||
use_sideband ? " side-band-64k" : "",
|
use_sideband ? " side-band-64k" : "",
|
||||||
args->quiet ? " quiet" : "");
|
quiet ? " quiet" : "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
packet_buf_write(&req_buf, "%s %s %s",
|
packet_buf_write(&req_buf, "%s %s %s",
|
||||||
|
@ -101,10 +101,11 @@ test_expect_success TTY 'push -q suppresses progress' '
|
|||||||
! grep "Writing objects" err
|
! grep "Writing objects" err
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure TTY 'push --no-progress suppresses progress' '
|
test_expect_success TTY 'push --no-progress suppresses progress' '
|
||||||
ensure_fresh_upstream &&
|
ensure_fresh_upstream &&
|
||||||
|
|
||||||
test_terminal git push -u --no-progress upstream master >out 2>err &&
|
test_terminal git push -u --no-progress upstream master >out 2>err &&
|
||||||
|
! grep "Unpacking objects" err &&
|
||||||
! grep "Writing objects" err
|
! grep "Writing objects" err
|
||||||
'
|
'
|
||||||
|
|
||||||
|
12
transport.c
12
transport.c
@ -993,11 +993,15 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
|
|||||||
* Rules used to determine whether to report progress (processing aborts
|
* Rules used to determine whether to report progress (processing aborts
|
||||||
* when a rule is satisfied):
|
* when a rule is satisfied):
|
||||||
*
|
*
|
||||||
* 1. Report progress, if force_progress is 1 (ie. --progress).
|
* . Report progress, if force_progress is 1 (ie. --progress).
|
||||||
* 2. Don't report progress, if verbosity < 0 (ie. -q/--quiet ).
|
* . Don't report progress, if force_progress is 0 (ie. --no-progress).
|
||||||
* 3. Report progress if isatty(2) is 1.
|
* . Don't report progress, if verbosity < 0 (ie. -q/--quiet ).
|
||||||
|
* . Report progress if isatty(2) is 1.
|
||||||
**/
|
**/
|
||||||
transport->progress = force_progress || (verbosity >= 0 && isatty(2));
|
if (force_progress >= 0)
|
||||||
|
transport->progress = !!force_progress;
|
||||||
|
else
|
||||||
|
transport->progress = verbosity >= 0 && isatty(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int transport_push(struct transport *transport,
|
int transport_push(struct transport *transport,
|
||||||
|
Loading…
Reference in New Issue
Block a user