From patchwork Sat Nov 6 21:46:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12606615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E806C433F5 for ; Sat, 6 Nov 2021 21:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 422B06108D for ; Sat, 6 Nov 2021 21:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234197AbhKFVtz (ORCPT ); Sat, 6 Nov 2021 17:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234095AbhKFVtw (ORCPT ); Sat, 6 Nov 2021 17:49:52 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 077DFC061205 for ; Sat, 6 Nov 2021 14:47:10 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id u18so19599523wrg.5 for ; Sat, 06 Nov 2021 14:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nAgveEnnTUZ1IrS9pNMlRlq/C4CLz8miJeoiSauvwz8=; b=DA14c668Tr6Bln7aJLBqGosqkGU/fFc9Idcrm3l6nFgyGFnj5SaoEwArcadNHbvMZv FjEA6GCSKF6I8QPZ67gNbfGhNFyrDOP0UfX6eJ2uaP/MDlH3OBW5tDP6cTg5wqAj1A8x XdapdbaewckGxTwZmFuN2gIXpzPZybNBWAlxneVCi7/gvVnwzvYsCdOp1gLtK03k2cB8 J38TjJJvfaBNKJZX5sVEQTrYm1kCfIyVHkrzWqnQJVkRniYwmeXngbYSKXm9xIIs+1VB dLwxYE7O8MFUdu3ZSm+tQcY5RkQlKWDNGTCP+MG4LW0I/MKTGQZhVshtcED5qE3gsWx8 wb+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nAgveEnnTUZ1IrS9pNMlRlq/C4CLz8miJeoiSauvwz8=; b=ZzEzlPW6i8kmihyfkZBwGttjO70iRxBSLYP/f59WFF0xnlfkCZPy2aAP1oSAiQbHAT R+W8pMzeMPwwBPQSrtD37woMz9vyGBZwtC5XbfCfSmJGE8a4M/Hp+pS3Qs8cE4i5NvJZ 1p2HDMQcJF9/aFuqmi+DU1YZrWJjo+22+qfseD5RwiStkQyv0j4uJFNM+TbLCDE/tXqS 3rKLCxA8p3WQjgQofh00XIxpGw5eiLNARxqlU7aCYMMThHnKsRO+zbUrqNuAyYjUHkl6 tLCsRdc/nd+jog8CN/bKhC9rsZn0f66tl7+VQ5e9nJA6L/ofi4C8LDuKqNFKnansV6v4 0rXg== X-Gm-Message-State: AOAM530G/KTXSSguFeGviGJBprb3Q6A2EZbSsQNOX8rDQCmMNNeupeLl tK+5Evbei3KvKBNIyJOmAc8l7lBNp5yHJg== X-Google-Smtp-Source: ABdhPJwa04q2mEpntYfQQ2TIvcxpR2tiMJOaJd7RCZrg5e44Su4SVAHre3cIyCwE8+sLOOoTAVFNiw== X-Received: by 2002:a5d:4e52:: with SMTP id r18mr57542449wrt.224.1636235228466; Sat, 06 Nov 2021 14:47:08 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id f19sm12736630wmq.34.2021.11.06.14.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Nov 2021 14:47:07 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , John Cai , Sergey Organov , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 05/10] cat-file: move "usage" variable to cmd_cat_file() Date: Sat, 6 Nov 2021 22:46:57 +0100 Message-Id: X-Mailer: git-send-email 2.34.0.rc1.741.gab7bfd97031 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no benefit to defining this at a distance, and it makes the code harder to read as you've got to scroll up to see the usage that corresponds to the options. In subsequent commits I'll make use of usage_msg_opt(), which will be quite noisy if I have to use the long "cat_file_usage" variable, there's no other command being defined in this file, so let's rename it to just "usage". Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/cat-file.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 1df7f797cb6..6d0f645301b 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -618,18 +618,6 @@ static int batch_objects(struct batch_options *opt) return retval; } -static const char * const cat_file_usage[] = { - N_("git cat-file "), - N_("git cat-file (-e | -p) "), - N_("git cat-file ( -t | -s ) [--allow-unknown-type] "), - N_("git cat-file (--batch | --batch-check) [--batch-all-objects]\n" - " [--buffer] [--follow-symlinks] [--unordered]\n" - " [--textconv | --filters]"), - N_("git cat-file (--textconv | --filters )\n" - " [: | --path= ]"), - NULL -}; - static int git_cat_file_config(const char *var, const char *value, void *cb) { if (userdiff_config(var, value) < 0) @@ -664,6 +652,17 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix) struct batch_options batch = {0}; int unknown_type = 0; + const char * const usage[] = { + N_("git cat-file "), + N_("git cat-file (-e | -p) "), + N_("git cat-file ( -t | -s ) [--allow-unknown-type] "), + N_("git cat-file (--batch | --batch-check) [--batch-all-objects]\n" + " [--buffer] [--follow-symlinks] [--unordered]\n" + " [--textconv | --filters]"), + N_("git cat-file (--textconv | --filters )\n" + " [: | --path= ]"), + NULL + }; const struct option options[] = { OPT_GROUP(N_(" can be one of: blob, tree, commit, tag")), OPT_CMDMODE('t', NULL, &opt, N_("show object type"), 't'), @@ -700,7 +699,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix) git_config(git_cat_file_config, NULL); batch.buffer_output = -1; - argc = parse_options(argc, argv, prefix, options, cat_file_usage, 0); + argc = parse_options(argc, argv, prefix, options, usage, 0); if (opt) { if (batch.enabled && (opt == 'c' || opt == 'w')) @@ -708,35 +707,35 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix) else if (argc == 1) obj_name = argv[0]; else - usage_with_options(cat_file_usage, options); + usage_with_options(usage, options); } if (!opt && !batch.enabled) { if (argc == 2) { exp_type = argv[0]; obj_name = argv[1]; } else - usage_with_options(cat_file_usage, options); + usage_with_options(usage, options); } if (batch.enabled) { if (batch.cmdmode != opt || argc) - usage_with_options(cat_file_usage, options); + usage_with_options(usage, options); if (batch.cmdmode && batch.all_objects) die("--batch-all-objects cannot be combined with " "--textconv nor with --filters"); } if ((batch.follow_symlinks || batch.all_objects) && !batch.enabled) { - usage_with_options(cat_file_usage, options); + usage_with_options(usage, options); } if (force_path && opt != 'c' && opt != 'w') { error("--path= needs --textconv or --filters"); - usage_with_options(cat_file_usage, options); + usage_with_options(usage, options); } if (force_path && batch.enabled) { error("--path= incompatible with --batch"); - usage_with_options(cat_file_usage, options); + usage_with_options(usage, options); } if (batch.buffer_output < 0)