Skip to content

Commit

Permalink
check stderr with isatty() instead of stdout when deciding to show pr…
Browse files Browse the repository at this point in the history
…ogress

Make transport code (viz. transport.c::fetch_refs_via_pack() and
transport-helper.c::standard_options()) that decides to show progress
check if stderr is a terminal, instead of stdout. After all, progress
reports (via the API in progress.[ch]) are sent to stderr.

Update the documentation for git-clone to say "standard error" as well.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tay Ray Chuan authored and Junio C Hamano committed Dec 29, 2009
1 parent 902f235 commit 486a3d7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Documentation/git-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ objects from the source repository into a pack in the cloned repository.

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

--no-checkout::
Expand Down
2 changes: 1 addition & 1 deletion transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,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 @@ -476,7 +476,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.include_tag = data->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->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 @@ -26,7 +26,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;
};

Expand Down

0 comments on commit 486a3d7

Please sign in to comment.