Re: Making git push output quieter
- From
Nicolas Pitre <nico@cam.org>
- Date
- Aug 5, 2009, 19:51 UTC
- Message-ID
- <alpine.LFD.2.00.0908051545300.16073@xanadu.home>
- In-Reply-To
- <20090805192658.GI1033@spearce.org>
On Wed, 5 Aug 2009, Shawn O. Pearce wrote:
Show 62 quoted lines
> Albert Astals Cid <aacid@kde.org> wrote:
> > A Dimecres, 5 d'agost de 2009, Pau Garcia i Quiles va escriure:
> > > On Tue, Aug 4, 2009 at 11:27 PM, Albert Astals Cid<aacid@kde.org> wrote:
> > > > Hi, at KDE we are starting to try to use git and one of the things that's
> > > > bothering me is that git push is too verbose for our scripts.
> ...
> > > Have you tried redirecting only stdout to /dev/null, and keeping
> > > stderr to yourself ?
> >
> > Everything goes to stderr.
>
> Sadly our use of isatty to determine if progress/verbosity should
> be used is inconsistent. pack-objects.c, which is what you are
> talking about above, is using stderr to determine if progress should
> be enabled, but other code like transport.c, which is used on the
> client side, is using stdout. Hence the suggestion above to redirect
> stdout to /dev/null to try and shutoff the spew.
>
> $ git grep isatty
> builtin-commit.c: if (isatty(0))
> builtin-config.c: stdout_is_tty = isatty(1);
> builtin-pack-objects.c: progress = isatty(2);
> builtin-revert.c: if (isatty(0))
> builtin-shortlog.c: if (!nongit && !rev.pending.nr && isatty(0))
> builtin-unpack-objects.c: quiet = !isatty(2);
> color.c: stdout_is_tty = isatty(1);
> compat/winansi.c: if (!isatty(fileno(stream)))
> compat/winansi.c: if (!isatty(fileno(stream)))
> pack-redundant.c: if (!isatty(0)) {
> pager.c: if (!isatty(1))
> pager.c: if (isatty(2))
> transport.c: args.no_progress = args.quiet || (!transport->progress && !isatty(1));
> wt-status.c: * will have checked isatty on stdout).
>
> I'm thinking this might be a reasonable patch to apply, Junio/Nico?
>
> --8<--
> pack-objects: Display progress only if stdout is tty
>
> Client transports underneath git fetch display progress output only
> if stdout is a tty, allowing redirection of stdout to /dev/null (or
> a pipe) to silence progress but still report actual errors on stderr.
>
> Doing the same in pack-objects means push, bundle creation and
> repack can use the same trick to silence noisy progress progress,
> but still obtain real errors.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
> builtin-pack-objects.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
> index 961b639..0b9234a 100644
> --- a/builtin-pack-objects.c
> +++ b/builtin-pack-objects.c
> @@ -2110,7 +2110,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
> if (!pack_compression_seen && core_compression_seen)
> pack_compression_level = core_compression_level;
>
> - progress = isatty(2);
> + progress = isatty(1);Doesn't this break progress reporting on a push since stdout is never a tty in that case? Same issue on a fetch although in that case the progress level is provided explicitly by the caller.
Show 14 quoted lines
> for (i = 1; i < argc; i++) {
> const char *arg = argv[i];
>
> --
> 1.6.4.70.g9c084
>
>
> --
> Shawn.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>