Skip to content

Commit 53997a3

Browse files
committed
Merge branch 'tc/transport-verbosity'
* tc/transport-verbosity: transport: update flags to be in running order fetch and pull: learn --progress push: learn --progress transport->progress: use flag authoritatively clone: support multiple levels of verbosity push: support multiple levels of verbosity fetch: refactor verbosity option handling into transport.[ch] Documentation/git-push: put --quiet before --verbose Documentation/git-pull: put verbosity options before merge/fetch ones Documentation/git-clone: mention progress in -v Conflicts: transport.h
2 parents 66bce02 + 212cfe1 commit 53997a3

File tree

12 files changed

+92
-41
lines changed

12 files changed

+92
-41
lines changed

Documentation/fetch-options.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ ifndef::git-pull[]
7878
-q::
7979
--quiet::
8080
Pass --quiet to git-fetch-pack and silence any other internally
81-
used git commands.
81+
used git commands. Progress is not reported to the standard error
82+
stream.
8283

8384
-v::
8485
--verbose::
8586
Be verbose.
8687
endif::git-pull[]
88+
89+
--progress::
90+
Progress status is reported on the standard error stream
91+
by default when it is attached to a terminal, unless -q
92+
is specified. This flag forces progress status even if the
93+
standard error stream is not directed to a terminal.

Documentation/git-clone.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ objects from the source repository into a pack in the cloned repository.
102102

103103
--verbose::
104104
-v::
105-
Run verbosely.
105+
Run verbosely. Does not affect the reporting of progress status
106+
to the standard error stream.
106107

107108
--progress::
108109
Progress status is reported on the standard error stream

Documentation/git-pull.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ in a state that is hard to back out of in the case of a conflict.
3131
OPTIONS
3232
-------
3333

34+
-q::
35+
--quiet::
36+
This is passed to both underlying git-fetch to squelch reporting of
37+
during transfer, and underlying git-merge to squelch output during
38+
merging.
39+
40+
-v::
41+
--verbose::
42+
Pass --verbose to git-fetch and git-merge.
43+
3444
Options related to merging
3545
~~~~~~~~~~~~~~~~~~~~~~~~~~
3646

Documentation/git-push.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,21 @@ useful if you write an alias or script around 'git push'.
146146
receiver share many of the same objects in common. The default is
147147
\--thin.
148148

149+
-q::
150+
--quiet::
151+
Suppress all output, including the listing of updated refs,
152+
unless an error occurs. Progress is not reported to the standard
153+
error stream.
154+
149155
-v::
150156
--verbose::
151157
Run verbosely.
152158

153-
-q::
154-
--quiet::
155-
Suppress all output, including the listing of updated refs,
156-
unless an error occurs.
159+
--progress::
160+
Progress status is reported on the standard error stream
161+
by default when it is attached to a terminal, unless -q
162+
is specified. This flag forces progress status even if the
163+
standard error stream is not directed to a terminal.
157164

158165
include::urls-remotes.txt[]
159166

Documentation/merge-options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ option can be used to override --squash.
6767
Synonyms to --stat and --no-stat; these are deprecated and will be
6868
removed in the future.
6969

70+
ifndef::git-pull[]
7071
-q::
7172
--quiet::
7273
Operate quietly.
7374

7475
-v::
7576
--verbose::
7677
Be verbose.
78+
endif::git-pull[]
7779

7880
-X <option>::
7981
--strategy-option=<option>::

builtin/clone.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,17 @@ static const char * const builtin_clone_usage[] = {
3737
NULL
3838
};
3939

40-
static int option_quiet, option_no_checkout, option_bare, option_mirror;
40+
static int option_no_checkout, option_bare, option_mirror;
4141
static int option_local, option_no_hardlinks, option_shared, option_recursive;
4242
static char *option_template, *option_reference, *option_depth;
4343
static char *option_origin = NULL;
4444
static char *option_branch = NULL;
4545
static char *option_upload_pack = "git-upload-pack";
46-
static int option_verbose;
46+
static int option_verbosity;
4747
static int option_progress;
4848

4949
static struct option builtin_clone_options[] = {
50-
OPT__QUIET(&option_quiet),
51-
OPT__VERBOSE(&option_verbose),
50+
OPT__VERBOSITY(&option_verbosity),
5251
OPT_BOOLEAN(0, "progress", &option_progress,
5352
"force progress reporting"),
5453
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
@@ -462,7 +461,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
462461
die("could not create leading directories of '%s'", git_dir);
463462
set_git_dir(make_absolute_path(git_dir));
464463

465-
init_db(option_template, option_quiet ? INIT_DB_QUIET : 0);
464+
init_db(option_template, (option_verbosity < 0) ? INIT_DB_QUIET : 0);
466465

467466
/*
468467
* At this point, the config exists, so we do not need the
@@ -526,13 +525,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
526525
transport_set_option(transport, TRANS_OPT_DEPTH,
527526
option_depth);
528527

529-
if (option_quiet)
530-
transport->verbose = -1;
531-
else if (option_verbose)
532-
transport->verbose = 1;
533-
534-
if (option_progress)
535-
transport->progress = 1;
528+
transport_set_verbosity(transport, option_verbosity, option_progress);
536529

537530
if (option_upload_pack)
538531
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
@@ -641,7 +634,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
641634
opts.update = 1;
642635
opts.merge = 1;
643636
opts.fn = oneway_merge;
644-
opts.verbose_update = !option_quiet;
637+
opts.verbose_update = (option_verbosity > 0);
645638
opts.src_index = &the_index;
646639
opts.dst_index = &the_index;
647640

builtin/fetch.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum {
2828
};
2929

3030
static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
31+
static int progress;
3132
static int tags = TAGS_DEFAULT;
3233
static const char *depth;
3334
static const char *upload_pack;
@@ -57,6 +58,7 @@ static struct option builtin_fetch_options[] = {
5758
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
5859
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
5960
"allow updating of HEAD ref"),
61+
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
6062
OPT_STRING(0, "depth", &depth, "DEPTH",
6163
"deepen history of shallow clone"),
6264
OPT_END()
@@ -845,10 +847,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
845847
die("Where do you want to fetch from today?");
846848

847849
transport = transport_get(remote, NULL);
848-
if (verbosity >= 2)
849-
transport->verbose = verbosity <= 3 ? verbosity : 3;
850-
if (verbosity < 0)
851-
transport->verbose = -1;
850+
transport_set_verbosity(transport, verbosity, progress);
852851
if (upload_pack)
853852
set_option(TRANS_OPT_UPLOADPACK, upload_pack);
854853
if (keep)

builtin/push.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ static const char * const push_usage[] = {
1717
static int thin;
1818
static int deleterefs;
1919
static const char *receivepack;
20+
static int verbosity;
21+
static int progress;
2022

2123
static const char **refspec;
2224
static int refspec_nr;
@@ -105,13 +107,16 @@ static int push_with_options(struct transport *transport, int flags)
105107
{
106108
int err;
107109
int nonfastforward;
110+
111+
transport_set_verbosity(transport, verbosity, progress);
112+
108113
if (receivepack)
109114
transport_set_option(transport,
110115
TRANS_OPT_RECEIVEPACK, receivepack);
111116
if (thin)
112117
transport_set_option(transport, TRANS_OPT_THIN, "yes");
113118

114-
if (flags & TRANSPORT_PUSH_VERBOSE)
119+
if (verbosity > 0)
115120
fprintf(stderr, "Pushing to %s\n", transport->url);
116121
err = transport_push(transport, refspec_nr, refspec, flags,
117122
&nonfastforward);
@@ -204,8 +209,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
204209
int rc;
205210
const char *repo = NULL; /* default repository */
206211
struct option options[] = {
207-
OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET),
208-
OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
212+
OPT__VERBOSITY(&verbosity),
209213
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
210214
OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
211215
OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
@@ -220,6 +224,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
220224
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
221225
OPT_BIT('u', "set-upstream", &flags, "set upstream for git pull/status",
222226
TRANSPORT_PUSH_SET_UPSTREAM),
227+
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
223228
OPT_END()
224229
};
225230

git-pull.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test -z "$(git ls-files -u)" || die_conflict
3838
test -f "$GIT_DIR/MERGE_HEAD" && die_merge
3939

4040
strategy_args= diffstat= no_commit= squash= no_ff= ff_only=
41-
log_arg= verbosity=
41+
log_arg= verbosity= progress=
4242
merge_args=
4343
curr_branch=$(git symbolic-ref -q HEAD)
4444
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
@@ -50,6 +50,8 @@ do
5050
verbosity="$verbosity -q" ;;
5151
-v|--verbose)
5252
verbosity="$verbosity -v" ;;
53+
--progress)
54+
progress=--progress ;;
5355
-n|--no-stat|--no-summary)
5456
diffstat=--no-stat ;;
5557
--stat|--summary)
@@ -214,7 +216,7 @@ test true = "$rebase" && {
214216
done
215217
}
216218
orig_head=$(git rev-parse -q --verify HEAD)
217-
git fetch $verbosity --update-head-ok "$@" || exit 1
219+
git fetch $verbosity $progress --update-head-ok "$@" || exit 1
218220

219221
curr_head=$(git rev-parse -q --verify HEAD)
220222
if test -n "$orig_head" && test "$curr_head" != "$orig_head"

transport-helper.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,8 @@ static void standard_options(struct transport *t)
279279
char buf[16];
280280
int n;
281281
int v = t->verbose;
282-
int no_progress = v < 0 || (!t->progress && !isatty(2));
283282

284-
set_helper_option(t, "progress", !no_progress ? "true" : "false");
283+
set_helper_option(t, "progress", t->progress ? "true" : "false");
285284

286285
n = snprintf(buf, sizeof(buf), "%d", v + 1);
287286
if (n >= sizeof(buf))
@@ -576,7 +575,6 @@ static int push_refs(struct transport *transport,
576575
if (buf.len == 0)
577576
return 0;
578577

579-
transport->verbose = flags & TRANSPORT_PUSH_VERBOSE ? 1 : 0;
580578
standard_options(transport);
581579

582580
if (flags & TRANSPORT_PUSH_DRY_RUN) {

0 commit comments

Comments
 (0)