]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/repack.c: extract showing progress to a variable
authorTaylor Blau <me@ttaylorr.com>
Wed, 29 Sep 2021 01:55:15 +0000 (21:55 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Sep 2021 04:20:56 +0000 (21:20 -0700)
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>
builtin/repack.c

index fb745a7a0f5f38b38dab6cf8a9a8942caec123f9..ead4f48fdaac16e08231f30befa45c5e097ed210 100644 (file)
@@ -446,6 +446,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
        struct strbuf line = STRBUF_INIT;
        int i, ext, ret;
        FILE *out;
+       int show_progress = isatty(2);
 
        /* variables to be filled by option parsing */
        int pack_everything = 0;
@@ -719,7 +720,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
                        }
                        strbuf_release(&buf);
                }
-               if (!po_args.quiet && isatty(2))
+               if (!po_args.quiet && show_progress)
                        opts |= PRUNE_PACKED_VERBOSE;
                prune_packed_objects(opts);