builtin/repack.c: extract showing progress to a variable

We only ask whether stderr is a tty before calling 'prune_packed_objects()', but the subsequent patch will add another use. Extract this check into a variable so that both can use it without having to call 'isatty()' twice. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Sep 28, 2021 at 21:55 UTC 5f18e31f4642f4daf398d0903e3fb3233b86f174
1 file changed +2 -1
builtin/repack.c
+2 -1
@@ -446,6 +446,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
446 struct strbuf line = STRBUF_INIT;
447 int i, ext, ret;
448 FILE *out;
449 + int show_progress = isatty(2);
450
451 /* variables to be filled by option parsing */
452 int pack_everything = 0;
@@ -719,7 +720,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
720 }
721 strbuf_release(&buf);
722 }
722 - if (!po_args.quiet && isatty(2))
723 + if (!po_args.quiet && show_progress)
724 opts |= PRUNE_PACKED_VERBOSE;
725 prune_packed_objects(opts);
726