Thread (40 messages) 40 messages, 4 authors, 2021-09-23

Re: [PATCH 4/6] help: refactor "for_human" control flow in cmd_help()

flat view

From: Eric Sunshine <hidden>
Date: 2021-09-08 16:42:00

On Wed, Sep 8, 2021 at 11:24 AM Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
@@ -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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help