Re: [PATCH 4/6] help: refactor "for_human" control flow in cmd_help()
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Sep 8, 2021, 16:41 UTC
- Message-ID
- <CAPig+cQVsFvkLMXrm7d3mCUoJKj7x+0PNcAYJ0-uFHaqbRw0ag@mail.gmail.com>
- In-Reply-To
- <patch-4.6-e4bc7e57a6d-20210908T151949Z-avarab@gmail.com>
On Wed, Sep 8, 2021 at 11:24 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 19 quoted lines
> Instead of having two lines that call list_config_help(for_human)
> let's setup the pager and print the trailer conditionally. This makes
> it clearer at a glance how the two differ in behavior.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> @@ -574,13 +574,12 @@ int cmd_help(int argc, const char **argv, const char *prefix)
> - if (!for_human) {
> - list_config_help(for_human);
> - return 0;
> - }
> - setup_pager();
> + if (for_human)
> + setup_pager();
> list_config_help(for_human);
> - printf("\n%s\n", _("'git help config' for more information"));
> + if (for_human)
> + printf("\n%s\n", _("'git help config' for more information"));
> +For what it's worth, I find the original logic easier to reason about since it gets the "simple" case out of the way early, thus I don't have to keep as much (or any) state in mind as I'm reading the rest of the code. However, it's highly subjective, of course; just one person's opinion.