Skip to content

Commit c7707a4

Browse files
committed
Merge branch 'cb/transfer-no-progress' into maint
* cb/transfer-no-progress: push/fetch/clone --no-progress suppresses progress output
2 parents 0cfba96 + 01fdc21 commit c7707a4

File tree

7 files changed

+28
-21
lines changed

7 files changed

+28
-21
lines changed

builtin/clone.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static char *option_branch = NULL;
4545
static const char *real_git_dir;
4646
static char *option_upload_pack = "git-upload-pack";
4747
static int option_verbosity;
48-
static int option_progress;
48+
static int option_progress = -1;
4949
static struct string_list option_config;
5050
static struct string_list option_reference;
5151

@@ -60,8 +60,8 @@ static int opt_parse_reference(const struct option *opt, const char *arg, int un
6060

6161
static struct option builtin_clone_options[] = {
6262
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"),
6565
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
6666
"don't create a checkout"),
6767
OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),

builtin/fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ static int get_pack(int xd[2], char **pack_lockfile)
736736
}
737737
else {
738738
*av++ = "unpack-objects";
739-
if (args.quiet)
739+
if (args.quiet || args.no_progress)
740740
*av++ = "-q";
741741
}
742742
if (*hdr_arg)

builtin/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum {
3030
};
3131

3232
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;
3434
static int tags = TAGS_DEFAULT;
3535
static const char *depth;
3636
static const char *upload_pack;
@@ -78,7 +78,7 @@ static struct option builtin_fetch_options[] = {
7878
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
7979
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
8080
"allow updating of HEAD ref"),
81-
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
81+
OPT_BOOL(0, "progress", &progress, "force progress reporting"),
8282
OPT_STRING(0, "depth", &depth, "depth",
8383
"deepen history of shallow clone"),
8484
{ OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir",

builtin/push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static int thin;
1919
static int deleterefs;
2020
static const char *receivepack;
2121
static int verbosity;
22-
static int progress;
22+
static int progress = -1;
2323

2424
static const char **refspec;
2525
static int refspec_nr;
@@ -260,7 +260,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
260260
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
261261
OPT_BIT('u', "set-upstream", &flags, "set upstream for git pull/status",
262262
TRANSPORT_PUSH_SET_UPSTREAM),
263-
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
263+
OPT_BOOL(0, "progress", &progress, "force progress reporting"),
264264
OPT_END()
265265
};
266266

builtin/send-pack.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
5858
argv[i++] = "--thin";
5959
if (args->use_ofs_delta)
6060
argv[i++] = "--delta-base-offset";
61-
if (args->quiet)
61+
if (args->quiet || !args->progress)
6262
argv[i++] = "-q";
6363
if (args->progress)
6464
argv[i++] = "--progress";
@@ -250,6 +250,7 @@ int send_pack(struct send_pack_args *args,
250250
int allow_deleting_refs = 0;
251251
int status_report = 0;
252252
int use_sideband = 0;
253+
int quiet_supported = 0;
253254
unsigned cmds_sent = 0;
254255
int ret;
255256
struct async demux;
@@ -263,8 +264,8 @@ int send_pack(struct send_pack_args *args,
263264
args->use_ofs_delta = 1;
264265
if (server_supports("side-band-64k"))
265266
use_sideband = 1;
266-
if (!server_supports("quiet"))
267-
args->quiet = 0;
267+
if (server_supports("quiet"))
268+
quiet_supported = 1;
268269

269270
if (!remote_refs) {
270271
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
@@ -302,17 +303,18 @@ int send_pack(struct send_pack_args *args,
302303
} else {
303304
char *old_hex = sha1_to_hex(ref->old_sha1);
304305
char *new_hex = sha1_to_hex(ref->new_sha1);
306+
int quiet = quiet_supported && (args->quiet || !args->progress);
305307

306308
if (!cmds_sent && (status_report || use_sideband || args->quiet)) {
307309
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" : "");
312314
}
313315
else
314316
packet_buf_write(&req_buf, "%s %s %s",
315-
old_hex, new_hex, ref->name);
317+
old_hex, new_hex, ref->name);
316318
ref->status = status_report ?
317319
REF_STATUS_EXPECTING_REPORT :
318320
REF_STATUS_OK;

t/t5523-push-upstream.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ test_expect_success TTY 'push -q suppresses progress' '
101101
! grep "Writing objects" err
102102
'
103103

104-
test_expect_failure TTY 'push --no-progress suppresses progress' '
104+
test_expect_success TTY 'push --no-progress suppresses progress' '
105105
ensure_fresh_upstream &&
106106
107107
test_terminal git push -u --no-progress upstream master >out 2>err &&
108+
! grep "Unpacking objects" err &&
108109
! grep "Writing objects" err
109110
'
110111

transport.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,11 +993,15 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
993993
* Rules used to determine whether to report progress (processing aborts
994994
* when a rule is satisfied):
995995
*
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.
9991000
**/
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);
10011005
}
10021006

10031007
int transport_push(struct transport *transport,

0 commit comments

Comments
 (0)