From f66d1423f528403a33e8984f765801deb1b9cb97 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 16 Jan 2025 13:35:53 -0800 Subject: builtin: send usage() help text to standard output Using the show_usage_and_exit_if_asked() helper we introduced earlier, fix callers of usage() that want to show the help text when explicitly asked by the end-user. The help text now goes to the standard output stream for them. These are the bog standard "if we got only '-h', then that is a request for help" callers. Their if (argc == 2 && !strcmp(argv[1], "-h")) usage(message); are simply replaced with show_usage_and_exit_if_asked(argc, argv, message); With this, the built-ins tested by t0012 all send their help text to their standard output stream, so the check in t0012 that was half tightened earlier is now fully tightened to insist on standard error stream being empty. Acked-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/diff-tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'builtin/diff-tree.c') diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 40804e7b48..e31cc797fe 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -122,8 +122,7 @@ int cmd_diff_tree(int argc, int read_stdin = 0; int merge_base = 0; - if (argc == 2 && !strcmp(argv[1], "-h")) - usage(diff_tree_usage); + show_usage_if_asked(argc, argv, diff_tree_usage); git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ -- cgit v1.2.3