git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Making git push output quieter

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 5, 2009, 19:26 UTC
Message-ID
<20090805192658.GI1033@spearce.org>
In-Reply-To
<200908052113.06373.aacid@kde.org>
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);
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
 
-- 
1.6.4.70.g9c084


-- 
Shawn.
Previous: Albert Astals CidNext: Nicolas Pitre
Message 4 of 19 in “Making git push output quieter”
  1. Albert Astals CidAug 4, 2009
  2. Pau Garcia i QuilesAug 4, 2009
  3. Albert Astals CidAug 5, 2009
  4. Shawn O. PearceAug 5, 2009
  5. Nicolas PitreAug 5, 2009
  6. Jeff KingAug 5, 2009
  7. 1/3 push: add --quiet flagJeff King, Aug 5, 2009
  8. 2/3 transport: pass "quiet" flag to pack-objectsJeff King, Aug 5, 2009
  9. 3/3 transport: don't show push status if --quiet is givenJeff King, Aug 5, 2009
  10. Sverre RabbelierAug 5, 2009
  11. Avery PennarunAug 5, 2009
  12. Sverre RabbelierAug 5, 2009
  13. Junio C HamanoAug 5, 2009
  14. Jeff KingAug 5, 2009
  15. Junio C HamanoAug 5, 2009
  16. Jeff KingAug 5, 2009
  17. Sebastian PippingAug 31, 2009
  18. Jeff KingAug 31, 2009
  19. Sebastian PippingAug 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.