From patchwork Mon Mar 16 21:28:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 11441347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37C0A1874 for ; Mon, 16 Mar 2020 21:29:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18C7E206C0 for ; Mon, 16 Mar 2020 21:29:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="lRXkulNv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732686AbgCPV3G (ORCPT ); Mon, 16 Mar 2020 17:29:06 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:51222 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732567AbgCPV3F (ORCPT ); Mon, 16 Mar 2020 17:29:05 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 40BD7C030A; Mon, 16 Mar 2020 17:29:03 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=sXp5zjDPnKHDmUbXRaPWFgldt FQ=; b=lRXkulNv/TSiXwh3R9E8xSPPeYmG5bHfHF2Qp0mxL3LtIQYPkeE9MwBhH 8qF4ZtZyO0oIJDWO0ggn4mtmKjqf9+8dTuuSmQzmyzcGwbHPQKzBhdbElMVYpE/q hIUR9t2BP0HHvSYWp3PpUP8oqUUiCHdM1v/rs/LlFAzuPXt9Qw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=sasl; b=c/5DhrcBb97bbgGpb2q 56rdQ/WxTpfWIZ+oNyHsWy26jeYJmmETx72IXr51hMUQR/7LirE7BDU30/ozBAlB zOFFjh+EtoFWRkcBIxDikoMUUn/Qkk4JxTLReiZY9YIcMKTbnSzYco6H2KKw/5xf YqjSLILJOF5m8vvPUmZ9sjP4= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 398A0C0309; Mon, 16 Mar 2020 17:29:03 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.74.119.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 7FC77C0303; Mon, 16 Mar 2020 17:29:00 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 1/3] parse-options: teach "git cmd -h" to show alias as alias Date: Mon, 16 Mar 2020 14:28:55 -0700 Message-Id: <20200316212857.259093-2-gitster@pobox.com> X-Mailer: git-send-email 2.26.0-rc1-11-g30e9940356 In-Reply-To: <20200316212857.259093-1-gitster@pobox.com> References: <20200316212857.259093-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: 26D0994E-67CD-11EA-BA25-8D86F504CC47-77302942!pb-smtp21.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There is a long-standing NEEDSWORK comment that complains about inconsistency between how an aliased option ("git clone --recurse" which is the only one that currently exists) gives a help text in a usage-error message vs "git cmd -h"). Get rid of it and then make sure we say an option is an alias for another, instead of repeating the same short help text for both, which leads to "they seem to do the same---is there any subtle difference?" puzzlement to end-users. Signed-off-by: Junio C Hamano --- * I couldn't easily see how to trigger usage_with_options() with the original options[], which is the potential cause of the inconsistency the NEEDSWORK comment mentions. But if there were, this should take care of it. Our test suite did not have an example, though. parse-options.c | 9 +++------ t/t0040-parse-options.sh | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/parse-options.c b/parse-options.c index 63d6bab60c..c57618d537 100644 --- a/parse-options.c +++ b/parse-options.c @@ -648,6 +648,7 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx, int short_name; const char *long_name; const char *source; + struct strbuf help = STRBUF_INIT; int j; if (newopt[i].type != OPTION_ALIAS) @@ -659,6 +660,7 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx, if (!long_name) BUG("An alias must have long option name"); + strbuf_addf(&help, _("alias of --%s"), source); for (j = 0; j < nr; j++) { const char *name = options[j].long_name; @@ -669,15 +671,10 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx, if (options[j].type == OPTION_ALIAS) BUG("No please. Nested aliases are not supported."); - /* - * NEEDSWORK: this is a bit inconsistent because - * usage_with_options() on the original options[] will print - * help string as "alias of %s" but "git cmd -h" will - * print the original help string. - */ memcpy(newopt + i, options + j, sizeof(*newopt)); newopt[i].short_name = short_name; newopt[i].long_name = long_name; + newopt[i].help = strbuf_detach(&help, NULL); break; } diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 3483b72db4..f8178ee4e3 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -54,7 +54,7 @@ Alias -A, --alias-source get a string -Z, --alias-target - get a string + alias of --alias-source EOF From patchwork Mon Mar 16 21:28:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 11441343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 856C06CA for ; Mon, 16 Mar 2020 21:29:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66165206C0 for ; Mon, 16 Mar 2020 21:29:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="JWFK5FH6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732679AbgCPV3E (ORCPT ); Mon, 16 Mar 2020 17:29:04 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:61869 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732672AbgCPV3E (ORCPT ); Mon, 16 Mar 2020 17:29:04 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id CCFAF613D3; Mon, 16 Mar 2020 17:29:03 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=ExgHhty1tvPvlQw5fcN9ei9Av gM=; b=JWFK5FH6CCLTJROE6LksmtBL5nSl5jxNgIjAORTBoQdQDDzTcMO6I/xm7 A/UG73KXWN+vW4cdZN1E0QFeR+m88JMy2F4fyvwsXAeG3QoKQwXl883d5V6cBdGH zf2TJ0PWogkhQtHDc9ak8udpa53M7fI09BZmcam376sUu6IuJc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=sasl; b=Xd0Q8V8mi5A31IZzcQX PeifgaLSsVD7IPVH7b7tNU3+DMxrfd8rdbapl6iEJKdbmJ2KUuO/MCTTRRaEJe1r 1Hthnfc+B9QKpJ+FHIddp1ZoNhY1cR8pByUQ6txzJTgjTDSC0vCV49QvDuYdVDt6 0DDoQ6tNNCPRMRW3hKy0PNN0= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id C07B8613D2; Mon, 16 Mar 2020 17:29:03 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.74.119.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 02262613D1; Mon, 16 Mar 2020 17:29:02 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 2/3] clone: reorder --recursive/--recurse-submodules Date: Mon, 16 Mar 2020 14:28:56 -0700 Message-Id: <20200316212857.259093-3-gitster@pobox.com> X-Mailer: git-send-email 2.26.0-rc1-11-g30e9940356 In-Reply-To: <20200316212857.259093-1-gitster@pobox.com> References: <20200316212857.259093-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: 284C3292-67CD-11EA-8118-C28CBED8090B-77302942!pb-smtp1.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The previous step made an option that is an alias to another option identify itself as an alias to the latter. Because it is easier to scan the list when a pointer goes backward to what a reader already has seen, mention "recurse-submodules" first with its true short help string, and then "recurse" with the statement that it is a synonym to "recurse-submodules". Signed-off-by: Junio C Hamano --- The history of --recursive/--recurse-submodules options dates back to ccdd3da6 (clone: add the --recurse-submodules option as alias for --recursive, 2010-11-04), where we decided to encourage use of more descriptive "--recurse-submodules" over "--recursive" which does not say to what extent the process is allowed to recurse. Documentation/git-clone.txt mentions only "--recurse-submodules" for this exact reason, and it may not be a bad idea to start planning to deprecate the alias "--recursive". But that obviously is a separate topic. builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/clone.c b/builtin/clone.c index 1ad26f4d8c..54b0acbe73 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -102,10 +102,10 @@ static struct option builtin_clone_options[] = { N_("don't use local hardlinks, always copy")), OPT_BOOL('s', "shared", &option_shared, N_("setup as shared repository")), - OPT_ALIAS(0, "recursive", "recurse-submodules"), { OPTION_CALLBACK, 0, "recurse-submodules", &option_recurse_submodules, N_("pathspec"), N_("initialize submodules in the clone"), PARSE_OPT_OPTARG, recurse_submodules_cb, (intptr_t)"." }, + OPT_ALIAS(0, "recursive", "recurse-submodules"), OPT_INTEGER('j', "jobs", &max_jobs, N_("number of submodules cloned in parallel")), OPT_STRING(0, "template", &option_template, N_("template-directory"), From patchwork Mon Mar 16 21:28:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 11441349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC1E26CA for ; Mon, 16 Mar 2020 21:29:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C83820679 for ; Mon, 16 Mar 2020 21:29:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=pobox.com header.i=@pobox.com header.b="ABcsQle3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732695AbgCPV3J (ORCPT ); Mon, 16 Mar 2020 17:29:09 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:64761 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732567AbgCPV3J (ORCPT ); Mon, 16 Mar 2020 17:29:09 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id A4A8CAF908; Mon, 16 Mar 2020 17:29:07 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=bF9wjiUuGT5wkQTEUz5a0OI8A GE=; b=ABcsQle3wV9tqfvbnCdebS3z9Af08L4e0DjZpl2VmH3kBEcE94S/N2Xe+ /JaggIJgp5IU1KidazI3XQtbWfuMmio9EXTXjBExWO6MF/4l8KvnhyQSnxigmZJS 2dO6FcGg21bdDYwn/5NoGahkjAO3E11hPvXqk6urokH3AOnprs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=sasl; b=X9VveGI75fudHp1MWKy HQXePweuiD6GDFACgjz20MOn6g9brIn3mYz6rOjl/UHi+atDJBunuXrlTIhL1IJY I15vV9Pvscjzw+RTpfonxdgh9xsNsMm9+0Os59jmlLJ0JuKkejwltgd+zWKanWIY eKcnNUBqxvjOykdzMcG5036c= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 9CC3CAF907; Mon, 16 Mar 2020 17:29:07 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [34.74.119.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id E828BAF900; Mon, 16 Mar 2020 17:29:04 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 3/3] log: give --[no-]use-mailmap a more sensible synonym --[no-]mailmap Date: Mon, 16 Mar 2020 14:28:57 -0700 Message-Id: <20200316212857.259093-4-gitster@pobox.com> X-Mailer: git-send-email 2.26.0-rc1-11-g30e9940356 In-Reply-To: <20200316212857.259093-1-gitster@pobox.com> References: <20200316212857.259093-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: 297406B8-67CD-11EA-A633-B0405B776F7B-77302942!pb-smtp20.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The option name "--use-mailmap" looks OK, but it becomes awkward when you have to negate it, i.e. "--no-use-mailmap". I, perhaps with many other users, always try "--no-mailmap" and become unhappy to see it fail. Add an alias "--[no-]mailmap" to remedy this. Signed-off-by: Junio C Hamano --- Documentation/git-log.txt | 1 + builtin/log.c | 1 + 2 files changed, 2 insertions(+) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index bed09bb09e..619577f23b 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -49,6 +49,7 @@ OPTIONS Print out the ref name given on the command line by which each commit was reached. +--[no-]mailmap:: --[no-]use-mailmap:: Use mailmap file to map author and committer names and email addresses to canonical real names and email addresses. See diff --git a/builtin/log.c b/builtin/log.c index 83a4a6188e..ca1e789ba0 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -173,6 +173,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, OPT__QUIET(&quiet, N_("suppress diff output")), OPT_BOOL(0, "source", &source, N_("show source")), OPT_BOOL(0, "use-mailmap", &mailmap, N_("Use mail map file")), + OPT_ALIAS(0, "mailmap", "use-mailmap"), OPT_STRING_LIST(0, "decorate-refs", &decorate_refs_include, N_("pattern"), N_("only decorate refs that match ")), OPT_STRING_LIST(0, "decorate-refs-exclude", &decorate_refs_exclude,