Re: To page or not to page
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 2, 2008, 06:19 UTC
- Message-ID
- <7vd4o5xm62.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <20080502060930.GA1079@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> @@ -267,103 +270,103 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
> return 0;
> }
>
> +static struct cmd_struct commands[] = {
> + { "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
> + { "annotate", cmd_annotate, RUN_SETUP },
> + { "apply", cmd_apply },
> + { "archive", cmd_archive },
> + { "blame", cmd_blame, RUN_SETUP },
> + { "branch", cmd_branch, RUN_SETUP },
> + { "bundle", cmd_bundle },
> + { "cat-file", cmd_cat_file, RUN_SETUP },...
Show 20 quoted lines
> +};
> ...
> @@ -380,6 +383,31 @@ static void handle_internal_command(int argc, const char **argv)
> }
> }
>
> +void set_command_pager(const char *cmd, int use_pager)
> +{
> + int i;
> + for (i = 0; i < ARRAY_SIZE(commands); i++) {
> + struct cmd_struct *p = commands+i;
> + if (!strcmp(p->cmd, cmd)) {
> + if (use_pager)
> + p->option |= USE_PAGER;
> + else
> + p->option &= ~USE_PAGER;
> + return;
> + }
> + }
> +}Heh, I like it. I briefly thought that pager.cat-file may wreak havoc on scripts, but our pager machanism should be clever enough not to, and cat-file is a valid variable name in the configuration file format ;-).