From patchwork Fri Sep 24 16:51:44 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: 12516061 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 1A86FC433F5 for ; Fri, 24 Sep 2021 16:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F24BF61250 for ; Fri, 24 Sep 2021 16:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344095AbhIXQx0 (ORCPT ); Fri, 24 Sep 2021 12:53:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233932AbhIXQxZ (ORCPT ); Fri, 24 Sep 2021 12:53:25 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC878C061571 for ; Fri, 24 Sep 2021 09:51:51 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id r23so4010726wra.6 for ; Fri, 24 Sep 2021 09:51:51 -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=QoOR07aVizwggee0Ov8YtUl1o/rRUmBtl3kd3iu8P0g=; b=TcHU48WgHxnZJjRuH/Wf/Hq+JlD6YPctzDmSJu4XVEt1H/H/edKHm00ahmu95rOn58 SJe5wy5owmQi7bwqIbnzX2MQWqd1v8I/rLlwc0jU2Gj6P5XIZorY40+PsWWkdDkZ11P+ 5FLQCtCkAqfMJIRAU/va6PBYQz6VhcKHuXwwWmiZZI/kj8/VV9KsPNOk7AvXlqbh6xiK jEvGYX7yPY0jHpleQsbtdDipa0f5HlIol3tz/mwo5mhZnT3OT6J4yJ06ShHY2JQJXJ2Z 0ekybZewhnYWI7SclSy3A69tgVvU+c9f77ZADAQPLceiTYgxvVSlhTtt4ZGTOQGvMaS4 Ocrw== 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=QoOR07aVizwggee0Ov8YtUl1o/rRUmBtl3kd3iu8P0g=; b=jtxgnwy2Um5w3FCNPgUvZ1bhYjmC1zAkTD5m5CDA5qazGGbnqaYmik/0FJa5k9DdDA kHDc/NKoyinpwlr97SR8pytmp9HJn74UDdVr8C0+3uGYaUJ2Jonw00U4DKYyjZbKTlin drcevoyZ/mcy6DvkL9xJVWwZaLSzkE5Whr9Uuxyp0N7TkMWmGpl+kShUB9aovqluj3DS MVjPoK9lLFrcIE3jR3cVu138TFE90Z/MChMleDEiKQBEe7sW26xDTflmtXdBe7tdsQMb nbkoVQnk+iTGj27n93T/t9jbgmtJ0epfiojom6TsYpwqXv0GtghRoRbRdDpVh/ts4jNN QCUg== X-Gm-Message-State: AOAM530/pw08tKrzCH78Uyj5i67eALRmMIYRxTQ1YheyviyLnl8rXre1 /bCA7XRo6CmZgB+1F2RBjhSHp14rx/sD7A== X-Google-Smtp-Source: ABdhPJwJFFF+AMoQKNR6SifqQz5Bt3LnCIaU8NZoUr4wGj4wuEzsM2uZJyifFzNZ082vChIxMRdsFg== X-Received: by 2002:a7b:cc96:: with SMTP id p22mr3217526wma.67.1632502309998; Fri, 24 Sep 2021 09:51:49 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id f1sm8929623wrc.66.2021.09.24.09.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:51:49 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ignacy Gawedzki , =?utf-8?b?w4Z2?= =?utf-8?b?YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/3] show-ref: remove unused custom handling of -h Date: Fri, 24 Sep 2021 18:51:44 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1285.g7aff81f6560 In-Reply-To: References: <20210924141920.ezfpyf4uutob2h5z@zenon.in.qult.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since b92891f9783 (parseopt: add PARSE_OPT_NO_INTERNAL_HELP, 2009-03-08) parse_options() has handled "-h" unless told not to, so when show-ref was migrated to parse_options() in 69932bc6117 (show-ref: migrate to parse-options, 2009-06-20) the custom "-h" handling that was retained did nothing. The option was then hidden in e62b3935056 (Show usage string for 'git show-ref -h', 2009-11-09), but that OPT_BOOLEAN didn't do anything. Let's just remove this dead code. Reported-by: Ignacy Gawedzki Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/show-ref.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 7f8a5332f83..8cefb663282 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -163,8 +163,6 @@ static const struct option show_ref_options[] = { OPT_BOOL(0, "heads", &heads_only, N_("only show heads (can be combined with tags)")), OPT_BOOL(0, "verify", &verify, N_("stricter reference checking, " "requires exact ref path")), - OPT_HIDDEN_BOOL('h', NULL, &show_head, - N_("show the HEAD reference, even if it would be filtered out")), OPT_BOOL(0, "head", &show_head, N_("show the HEAD reference, even if it would be filtered out")), OPT_BOOL('d', "dereference", &deref_tags, From patchwork Fri Sep 24 16:51:45 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: 12516063 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 B837DC4332F for ; Fri, 24 Sep 2021 16:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9719261100 for ; Fri, 24 Sep 2021 16:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344104AbhIXQx0 (ORCPT ); Fri, 24 Sep 2021 12:53:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344084AbhIXQx0 (ORCPT ); Fri, 24 Sep 2021 12:53:26 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAF13C061571 for ; Fri, 24 Sep 2021 09:51:52 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id u18so29404450wrg.5 for ; Fri, 24 Sep 2021 09:51:52 -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=AhQePB5TT8C0PstkXR2LYBE/KgU3p9wAhukUAsr7B8o=; b=Io4P+SU0jFTMjpYc8xfabbh1vjLPjAwIGVy3kaF55h/CAuvo/g0QZtYGBotA6j9FZm KMuvWx0RUdfsvpmNfkWSIUWOOBr76rdBW98UbYMkxwathG1usdPpcbzYkFxp9SW5mT7u eOw0LRhau07D+E5RKrowB0R7rQSXcz13X1UxBmruWS7DIWW0sXVFgdE68o9ctCGP0taf C6aeIE/ZnNdBBRQ5KGkF3T4Vh0brXm/P4/9Uj731m1r3+Z5nkUIiwI4IKUpRebTQgTsT KILzMxeIgjO52gozUlgfALrV8rWCEJqaG2PGfVTlKl4E0I8A87VTIW4XuP9w4sbDw82t dM7Q== 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=AhQePB5TT8C0PstkXR2LYBE/KgU3p9wAhukUAsr7B8o=; b=sv4J3M4Zn+DtgSJyq4+dDhXal0GW5dlXyQgIm/WpNYsi54bfD0yG9WiqwawHQ50YOT lL5HTHiqA5QgCMSGK3eQuXewQ7wYB7dEsCpSk/iQUSkSMkk9kkIN3kxUzLa0ivPapFLu 8zt81l6XEyqRevrxtnAbshi19DA2uAevPogLwHTua7AOPYtaKcLjbLPtMfQA4dY3Oc2u Fo6B23FgaiEb3MmBnTv/AcfrOF3M7EafasCCjU8b6CEfA9BSw2nVxj+uURpmrpW4ft1H lUIV/WNQeov6Hb2DmaBxVDhjrBP3nKlS7QMAc/7uuxf+i2TIAJGxWzbFM/mhhwTA+w+e bgqw== X-Gm-Message-State: AOAM533PWraOq+An87+0ckPL05Rznk3ZiqSNTTfteoH6Sw9geNdBsAK9 G1xRU84HfZdVPMOIY3TxbPjS3o/xaUPurg== X-Google-Smtp-Source: ABdhPJzZ3T3xOOcUbAZ2iFNvQ4oQdNFjKj48zdHugTdEDSbDYLi5445Gngv5zQmkMd1PTecEpHcGlQ== X-Received: by 2002:a1c:4386:: with SMTP id q128mr3069609wma.129.1632502311102; Fri, 24 Sep 2021 09:51:51 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id f1sm8929623wrc.66.2021.09.24.09.51.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:51:50 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ignacy Gawedzki , =?utf-8?b?w4Z2?= =?utf-8?b?YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/3] ls-remote: remove documentation for custom -h option Date: Fri, 24 Sep 2021 18:51:45 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1285.g7aff81f6560 In-Reply-To: References: <20210924141920.ezfpyf4uutob2h5z@zenon.in.qult.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The custom handling of the "-h" option was broken in ba5f28bf79e (ls-remote: use parse-options api, 2016-01-19), first released with Git v2.8.0. We've been promising that it's a synonym of --head, but it's not. We could make this work again by supplying the PARSE_OPT_NO_INTERNAL_HELP flag to parse_options(), but if we were writing this command today we wouldn't make this an exception. Since it's been such a long time let's just remove this rather than restoring the exception to "-h" handling. Reported-by: Ignacy Gawedzki Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-ls-remote.txt | 1 - builtin/ls-remote.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt index 492e573856f..6e241640bd9 100644 --- a/Documentation/git-ls-remote.txt +++ b/Documentation/git-ls-remote.txt @@ -21,7 +21,6 @@ commit IDs. OPTIONS ------- --h:: --heads:: -t:: --tags:: diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index f4fd823af83..c5e68918b78 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -64,7 +64,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) N_("path of git-upload-pack on the remote host"), PARSE_OPT_HIDDEN }, OPT_BIT('t', "tags", &flags, N_("limit to tags"), REF_TAGS), - OPT_BIT('h', "heads", &flags, N_("limit to heads"), REF_HEADS), + OPT_BIT(0, "heads", &flags, N_("limit to heads"), REF_HEADS), OPT_BIT(0, "refs", &flags, N_("do not show peeled tags"), REF_NORMAL), OPT_BOOL(0, "get-url", &get_url, N_("take url..insteadOf into account")), From patchwork Fri Sep 24 16:51:46 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: 12516065 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 CDB68C433EF for ; Fri, 24 Sep 2021 16:51:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC66861107 for ; Fri, 24 Sep 2021 16:51:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344159AbhIXQx3 (ORCPT ); Fri, 24 Sep 2021 12:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344084AbhIXQx1 (ORCPT ); Fri, 24 Sep 2021 12:53:27 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B59EC061571 for ; Fri, 24 Sep 2021 09:51:53 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id t28so15957280wra.7 for ; Fri, 24 Sep 2021 09:51:53 -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=BfXfhGqrhwjajRcHSAvwweh8bmaxGD0F3ilPpXVbxBo=; b=jRUi3kh3NRD5q116q7ArI8cnnPvkdrG4buUzqtfkgrb5uEKwFtTC9+s9tKRjiyFsBh FCJ6z748wbWvajBc9IhAVtvtJL84C03k0qoe/nOcyW7zgjSlsLnJRZgAM/Zie6SW5cgg XrYyX5CEO+XedINIRyFyU9z362/D+A6mjtJjfqilZAOtgu9NoqIDqfi1pVMc2DHLAskR TDZc/sahAJuhj2kfQScquZA/hqkHY51qryk4CgnZZwW7UCtmIvwa/6EDxTEoAYj6cV33 V2IofkFdfLhHf9kW/8CudrzOV++64Ll1cfqd0tTKwqL/S/bvl2KeEn/JxbvOUBEdVlNi DHjw== 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=BfXfhGqrhwjajRcHSAvwweh8bmaxGD0F3ilPpXVbxBo=; b=a4PdOCO0k5d3gHxOwCztdWh0UACX/w0tN1J7xKfWQXq5nbyYTCNvUzPBcRAZqS1/Zq cf1GPVvozheOEzwoL0k3xCCVITHZs5TmA4faAU0RWDd1u9slyQ9tzzDDZLEaAjJ57LRT 4CCnJ6kmJvZYXQgAdTytP6HlEX6WD74Shra+W01HMHQqdVsCCV3yF8sUhdqLFgNz7gxm 83eC/Lm9BXmIz9P4J3Hlos/he3dW97dpGpaHwCg9JjFaE0o4amIrRYkE8wpaXo7hXdpC pvFUvJqgPRrzgekESwzkOPS/0D5hZKMrntFT00FGh7m3vlUuH9bXdAVM2/AXzKhJFNZd z+Sw== X-Gm-Message-State: AOAM530CWG8Yh8KRbwvjPOFbYxM+XY6FLsWgIosZ9c6XItDkxKufnZ6J Jr0nK7ZGG8EO8KLbe/XqR9HO347NT1p7Gg== X-Google-Smtp-Source: ABdhPJylSxVeLkwZpsJvWPjLc/yusUDcK8u/ir2AZoJqLdSFM6XYAiMDK+QF0LU1QhC55Z7rIypRqw== X-Received: by 2002:adf:fb89:: with SMTP id a9mr12698561wrr.164.1632502311947; Fri, 24 Sep 2021 09:51:51 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id f1sm8929623wrc.66.2021.09.24.09.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Sep 2021 09:51:51 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Ignacy Gawedzki , =?utf-8?b?w4Z2?= =?utf-8?b?YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 3/3] grep: pass PARSE_OPT_NO_INTERNAL_HELP, fix odd -h handling Date: Fri, 24 Sep 2021 18:51:46 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1285.g7aff81f6560 In-Reply-To: References: <20210924141920.ezfpyf4uutob2h5z@zenon.in.qult.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The "grep" command supports both "-h" and "-H" options, along with a mandatory pattern, but this has been partially usurped by the "-h" handling in parse_options(). The reason it's just been "odd" instead of a bug is that we'll only print out "-h" usage with parse_options() if there's no further non-option arguments, so instead of printing this brief blurb on a stand-alone -h we'd print out the full usage: $ git grep -H fatal: no pattern given But for the aforementioned reason a "git grep -h " would work, we wouldn't take the !PARSE_OPT_NO_INTERNAL_HELP branch in parse_options_step(), would handle our own custom 'h' option, and builtin/grep.c itself would know what to do at that point. Reported-by: Ignacy Gawedzki Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/grep.c | 3 ++- t/t0012-help.sh | 4 +++- t/t7810-grep.sh | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index 51278b01fa2..a2d6704aa41 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -981,7 +981,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) */ argc = parse_options(argc, argv, prefix, options, grep_usage, PARSE_OPT_KEEP_DASHDASH | - PARSE_OPT_STOP_AT_NON_OPTION); + PARSE_OPT_STOP_AT_NON_OPTION | + PARSE_OPT_NO_INTERNAL_HELP); grep_commit_pattern_type(pattern_type_arg, &opt); if (use_index && !startup_info->have_repository) { diff --git a/t/t0012-help.sh b/t/t0012-help.sh index 913f34c8e9d..0b623fe794a 100755 --- a/t/t0012-help.sh +++ b/t/t0012-help.sh @@ -90,7 +90,9 @@ test_expect_success 'git help succeeds without git.html' ' ' test_expect_success 'generate builtin list' ' - git --list-cmds=builtins >builtins + git --list-cmds=builtins >builtins && + grep -v "^grep$" builtins >builtins+ && + mv builtins+ builtins ' while read builtin diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 6b6423a07c3..4c2777120b0 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -11,6 +11,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh +test_expect_success 'usage' ' + test_expect_code 128 git grep -h +' + test_invalid_grep_expression() { params="$@" && test_expect_success "invalid expression: grep $params" '