Skip to content

Commit

Permalink
Merge branch 'tc/clone-v-progress'
Browse files Browse the repository at this point in the history
* tc/clone-v-progress:
  clone: use --progress to force progress reporting
  clone: set transport->verbose when -v/--verbose is used
  git-clone.txt: reword description of progress behaviour
  check stderr with isatty() instead of stdout when deciding to show progress

Conflicts:
	transport.c
  • Loading branch information
Junio C Hamano committed Jan 17, 2010
2 parents d060507 + 5a518ad commit 42aac96
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
12 changes: 9 additions & 3 deletions Documentation/git-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@ objects from the source repository into a pack in the cloned repository.

--quiet::
-q::
Operate quietly. This flag is also passed to the `rsync'
Operate quietly. Progress is not reported to the standard
error stream. This flag is also passed to the `rsync'
command when given.

--verbose::
-v::
Display the progress bar, even in case the standard output is not
a terminal.
Run verbosely.

--progress::
Progress status is reported on the standard error stream
by default when it is attached to a terminal, unless -q
is specified. This flag forces progress status even if the
standard error stream is not directed to a terminal.

--no-checkout::
-n::
Expand Down
6 changes: 6 additions & 0 deletions builtin-clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ static char *option_origin = NULL;
static char *option_branch = NULL;
static char *option_upload_pack = "git-upload-pack";
static int option_verbose;
static int option_progress;

static struct option builtin_clone_options[] = {
OPT__QUIET(&option_quiet),
OPT__VERBOSE(&option_verbose),
OPT_BOOLEAN(0, "progress", &option_progress,
"force progress reporting"),
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
"don't create a checkout"),
OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
Expand Down Expand Up @@ -526,6 +529,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_quiet)
transport->verbose = -1;
else if (option_verbose)
transport->verbose = 1;

if (option_progress)
transport->progress = 1;

if (option_upload_pack)
Expand Down
3 changes: 2 additions & 1 deletion t/t5702-clone-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ test_expect_success 'redirected clone' '
'
test_expect_success 'redirected clone -v' '
git clone -v "file://$(pwd)/parent" clone-redirected-v >out 2>err &&
git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
>out 2>err &&
test -s err
'
Expand Down
2 changes: 1 addition & 1 deletion transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static void standard_options(struct transport *t)
char buf[16];
int n;
int v = t->verbose;
int no_progress = v < 0 || (!t->progress && !isatty(1));
int no_progress = v < 0 || (!t->progress && !isatty(2));

set_helper_option(t, "progress", !no_progress ? "true" : "false");

Expand Down
2 changes: 1 addition & 1 deletion transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.include_tag = data->options.followtags;
args.verbose = (transport->verbose > 0);
args.quiet = (transport->verbose < 0);
args.no_progress = args.quiet || (!transport->progress && !isatty(1));
args.no_progress = args.quiet || (!transport->progress && !isatty(2));
args.depth = data->options.depth;

for (i = 0; i < nr_heads; i++)
Expand Down
2 changes: 1 addition & 1 deletion transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct transport {
int (*disconnect)(struct transport *connection);
char *pack_lockfile;
signed verbose : 3;
/* Force progress even if the output is not a tty */
/* Force progress even if stderr is not a tty */
unsigned progress : 1;
/*
* If transport is at least potentially smart, this points to
Expand Down

0 comments on commit 42aac96

Please sign in to comment.