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

[PATCH] checkout: default to quiet if !isatty(2).

From
Avery Pennarun <apenwarr@gmail.com>
Date
May 24, 2012, 06:05 UTC
Message-ID
<1337839534-7760-1-git-send-email-apenwarr@gmail.com>
In-Reply-To
<20120524054506.GA3440@sigill.intra.peff.net>

It would probably be better to have progress.c check isatty(2) all the time, but that wouldn't allow things like 'git push --progress' to force progress reporting to on, so I won't try to solve the general case right now.

Actual fix suggested by Jeff King.
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
---
 builtin/checkout.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index f1984d9..4ee833a 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -343,7 +343,7 @@ static int reset_tree(struct tree *tree, struct checkout_opts *o, int worktree)
 	opts.reset = 1;
 	opts.merge = 1;
 	opts.fn = oneway_merge;
-	opts.verbose_update = !o->quiet;
+	opts.verbose_update = !o->quiet && isatty(2);
 	opts.src_index = &the_index;
 	opts.dst_index = &the_index;
 	parse_tree(tree);
@@ -420,7 +420,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 		topts.update = 1;
 		topts.merge = 1;
 		topts.gently = opts->merge && old->commit;
-		topts.verbose_update = !opts->quiet;
+		topts.verbose_update = !opts->quiet && isatty(2);
 		topts.fn = twoway_merge;
 		if (opts->overwrite_ignore) {
 			topts.dir = xcalloc(1, sizeof(*topts.dir));
-- 
1.7.9.dirty
Previous: Jeff KingNext: Jeff King
Message 3 of 11 in “progress: don't print if !isatty(2).”
  1. progress: don't print if !isatty(2).Avery Pennarun, May 24, 2012
  2. Jeff KingMay 24, 2012
  3. checkout: default to quiet if !isatty(2).Avery Pennarun, May 24, 2012
  4. Jeff KingMay 24, 2012
  5. checkout: no progress messages if !isatty(2).Avery Pennarun, May 24, 2012
  6. Junio C HamanoMay 24, 2012
  7. Jeff KingMay 24, 2012
  8. Avery PennarunMay 24, 2012
  9. Avery PennarunMay 24, 2012
  10. Junio C HamanoMay 24, 2012
  11. Avery PennarunMay 24, 2012

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.