From patchwork Thu Oct 7 03:36:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Perrotta X-Patchwork-Id: 12540917 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 81DB1C433EF for ; Thu, 7 Oct 2021 03:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FBAA6120D for ; Thu, 7 Oct 2021 03:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239941AbhJGDjs (ORCPT ); Wed, 6 Oct 2021 23:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238333AbhJGDjr (ORCPT ); Wed, 6 Oct 2021 23:39:47 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C647AC061746 for ; Wed, 6 Oct 2021 20:37:54 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id z15so3335164qvj.7 for ; Wed, 06 Oct 2021 20:37:54 -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=i3TAMgrYVK3W7T/b5x9JPhB6YthV3zjDhUCRgOtbgP8=; b=Ie48untrT9JfnvnIsPAlkS2meQOABMTw63ZE8PLDFc0QQjKLbjohET9QOYtivjTB4H d79rPilItf7cqsAxXba2S3xDD64y3dkyS+DpZXDUzopEwY6+Fh81JY6dFIXCZ+S8prDO XWMGUWLPlx1jN55f4ywT551C1DhMgcv2KjbyX4AMzLrRXbIjJ97l6g1/xH6H9DFKAmad qsiYHz/pfSGKPl3+g4btENWwxDdsgSwZZPFOOuLSHkZgHW209o7OPbUo7QL5yzohweHL OwGO0tOWzoaruKjW5ZRj/wH4J0v6nBc5y8S46+m2+kV6/Kg9d1Voo8fa6+G0FeNGyATI nFgw== 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=i3TAMgrYVK3W7T/b5x9JPhB6YthV3zjDhUCRgOtbgP8=; b=0n3bLvM48yO8GXNjnsNNe+pZTycz7VscnhSmyinvsPdYsRa33AHMzRgO6q0V0Xis2k WZPt93oxXtoNcj6XA0TJlTMbxV5GFI+ciFSCNH/QW5lBCSCGYJA3AeGLytWo236rJ3oC 7Umlszpn3fPJlkNYKRDap7NRVvWniEnqAjVto36y2xIjNd+2FZd0R/vGnyg6qDyvxZDc 1NOVYorYtXbeK+SGlVrDBgkhI9lgusDIQ8r+Mhtdb9eSkpush3iNEdDV/iWByJU5eE5h AFpMWVdXl5ASGbcxykmZ680KvNHtj1vgecZQgMwGf9wvwdboCnIN3hmoSF59xq9JsaZ6 qzbQ== X-Gm-Message-State: AOAM531MfvGVfKSirNh6bT+I7TBAY0nFnXPS2BE/m76fZbKA2HZ5l3+r kZfMsEnAxezdnLPm7go6h38= X-Google-Smtp-Source: ABdhPJyY0Koqryi606H+1l00H4dXF/5X1kUBg1Zo0UMspXQ14JqpJ4pQ5TD6NdATXo24+JarAfuDfQ== X-Received: by 2002:a0c:de0e:: with SMTP id t14mr1752508qvk.41.1633577874005; Wed, 06 Oct 2021 20:37:54 -0700 (PDT) Received: from valhalla.. (cpee03f49946310-cm589630b5b38a.cpe.net.cable.rogers.com. [99.250.23.181]) by smtp.gmail.com with ESMTPSA id x6sm13892860qts.79.2021.10.06.20.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 20:37:53 -0700 (PDT) From: Thiago Perrotta To: carenas@gmail.com, gitster@pobox.com, bagasdotme@gmail.com, avarab@gmail.com Cc: Thiago Perrotta , git@vger.kernel.org Subject: [PATCH v6 1/3] send-email: terminate --git-completion-helper with LF Date: Wed, 6 Oct 2021 23:36:50 -0400 Message-Id: <20211007033652.80793-2-tbperrotta@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Unlike other Git subcommands, "git send-email" leaves its output an incomplete line when "--git-completion-helper" is asked. Be consistent by terminating the message with LF here. Signed-off-by: Thiago Perrotta --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-send-email.perl b/git-send-email.perl index e65d969d0b..d1731c1755 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -114,7 +114,7 @@ sub usage { } sub completion_helper { - print Git::command('format-patch', '--git-completion-helper'); + print Git::command('format-patch', '--git-completion-helper'), "\n"; exit(0); } From patchwork Thu Oct 7 03:36:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Perrotta X-Patchwork-Id: 12540923 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 9BBE1C433FE for ; Thu, 7 Oct 2021 03:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C16061058 for ; Thu, 7 Oct 2021 03:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240058AbhJGDjw (ORCPT ); Wed, 6 Oct 2021 23:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239881AbhJGDjs (ORCPT ); Wed, 6 Oct 2021 23:39:48 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78FBEC061746 for ; Wed, 6 Oct 2021 20:37:55 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id o13so3340334qvm.4 for ; Wed, 06 Oct 2021 20:37:55 -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=DBjDMclAxXWT/hB1dHABDNuB5atk8u6IqJA/WCSTlpw=; b=N/CQJsPWncbeOZt0FRuqmpv3bUSZMyBZ+enRhQ2UMW/U8YG31rhF9y6ZnYoDfWdUJV PJiJPwOJHnTvZJc5RyArUT9Ia3TV6CNb0+NI9KROrp/FcTQn3hfcIXTkIwFceDNjkIEN 14BSGjeudXb8t78tBYBgTh4XsHhNe1D/piaKi8iY3AlyWMbRcRQ6WQC92MyOXgUpvrkp VsD/c9jVLhr212XuJpi977oSPvUnFzA63BgyKfomwqzJ18x29WlP6o+ShDgSr1Pu8tfV OMSK9YHp+EUQibODC8sCVKaKSrsXpAvJRADFCUM92cDwZMLrE4gPacrc32iegR0vgeqw Yv3g== 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=DBjDMclAxXWT/hB1dHABDNuB5atk8u6IqJA/WCSTlpw=; b=IrYG844VnE+yMKF1jB0eDJo2GhGr46IlrJ+Rnw8C0O18qYtDXSvpGGYGe2LTJmi4bq BMWhsNya1lK4oq07u0j52rIIQ1UXn659rHnHXd34UKIkLUIjUfFvXOJ+bGck6v8zDbfr FNuXbc+DTnfK9XQW/VdOo9pzeUIJBs+y+d1WrQ9UBG7VBZkNLdVyiLwLXsLUOHFIVXUs y1101jWPwcJ8+T4SjAQS9wXi2E8VYQ+JlgRYIcas1pyGRoHEKT5PrzirHCvl/fCJjFG+ dER5+TVqRwUpRNuu3CVYwJW57H+Av++SFXKulpHKMa/G/F7zfzXpeyHMoJ8di2lEblS4 9TiQ== X-Gm-Message-State: AOAM531laLnHmFo7UTU19BNERE9PTNmbpnAwOzmruLUJeYLXVfHi0DFr I/1J2i/aXDryy+TbPQwEpGA= X-Google-Smtp-Source: ABdhPJzVtpl2HHNXg4oKCFoR20WPKS88pv25jHKQKgXaVDGWKm+R1h3GpMvYesWGK5GC4xDkT/nscw== X-Received: by 2002:a0c:dc81:: with SMTP id n1mr2072176qvk.36.1633577874744; Wed, 06 Oct 2021 20:37:54 -0700 (PDT) Received: from valhalla.. (cpee03f49946310-cm589630b5b38a.cpe.net.cable.rogers.com. [99.250.23.181]) by smtp.gmail.com with ESMTPSA id x6sm13892860qts.79.2021.10.06.20.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 20:37:54 -0700 (PDT) From: Thiago Perrotta To: carenas@gmail.com, gitster@pobox.com, bagasdotme@gmail.com, avarab@gmail.com Cc: Thiago Perrotta , git@vger.kernel.org Subject: [PATCH v6 2/3] send-email: programmatically generate bash completions Date: Wed, 6 Oct 2021 23:36:51 -0400 Message-Id: <20211007033652.80793-3-tbperrotta@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "git send-email --git-completion-helper" only prints "format-patch" flags. Make it print "send-email" flags as well, generating them programmatically from the usage. Extract flags from the three existing `GetOptions`. Introduce a uniq subroutine, otherwise --cc-cover, --to-cover and other flags would show up twice. Remove two extraneous flags: --h and --git-completion-helper. Add a completion test for "send-email --validate", a send-email flag. Signed-off-by: Thiago Perrotta Based-on-patch-by: Ævar Arnfjörð Bjarmason --- contrib/completion/git-completion.bash | 11 +------ git-send-email.perl | 43 +++++++++++++++++++------- t/t9902-completion.sh | 3 ++ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 4bdd27ddc8..1b73a4dcc0 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2359,16 +2359,7 @@ _git_send_email () return ;; --*) - __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to - --compose --confirm= --dry-run --envelope-sender - --from --identity - --in-reply-to --no-chain-reply-to --no-signed-off-by-cc - --no-suppress-from --no-thread --quiet --reply-to - --signed-off-by-cc --smtp-pass --smtp-server - --smtp-server-port --smtp-encryption= --smtp-user - --subject --suppress-cc= --suppress-from --thread --to - --validate --no-validate - $__git_format_patch_extra_options" + __gitcomp_builtin send-email "$__git_format_patch_extra_options" return ;; esac diff --git a/git-send-email.perl b/git-send-email.perl index d1731c1755..465e9867b9 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -40,7 +40,7 @@ package main; sub usage { print < +git send-email [options] git send-email --dump-aliases Composing: @@ -113,8 +113,23 @@ sub usage { exit(1); } +sub uniq { + my %seen; + grep !$seen{$_}++, @_; +} + sub completion_helper { - print Git::command('format-patch', '--git-completion-helper'), "\n"; + my ($options) = @_; + my @send_email_opts = map { + "--$_" + } map { + s/(?:[:=][si]|!)$//; + split /\|/, $_; + } keys %$options; + my @format_patch_opts = Git::command('format-patch', '--git-completion-helper'); + my @options = uniq @send_email_opts, @format_patch_opts; + @options = grep !/--git-completion-helper|--h/, @options; + print "@options\n"; exit(0); } @@ -425,10 +440,11 @@ sub config_regexp { my $key = "sendemail.identity"; $identity = Git::config(@repo, $key) if exists $known_config_keys{$key}; } -my $rc = GetOptions( - "identity=s" => \$identity, - "no-identity" => \$no_identity, +my %identity_options = ( + "identity=s" => \$identity, + "no-identity" => \$no_identity, ); +my $rc = GetOptions(%identity_options); usage() unless $rc; undef $identity if $no_identity; @@ -444,14 +460,17 @@ sub config_regexp { my $help; my $git_completion_helper; -$rc = GetOptions("h" => \$help, - "dump-aliases" => \$dump_aliases); +my %dump_aliases_options = ( + "h" => \$help, + "dump-aliases" => \$dump_aliases, +); +$rc = GetOptions(%dump_aliases_options); usage() unless $rc; die __("--dump-aliases incompatible with other options\n") if !$help and $dump_aliases and @ARGV; -$rc = GetOptions( +my %options = ( "sender|from=s" => \$sender, - "in-reply-to=s" => \$initial_in_reply_to, + "in-reply-to=s" => \$initial_in_reply_to, "reply-to=s" => \$reply_to, "subject=s" => \$initial_subject, "to=s" => \@getopt_to, @@ -508,7 +527,8 @@ sub config_regexp { "batch-size=i" => \$batch_size, "relogin-delay=i" => \$relogin_delay, "git-completion-helper" => \$git_completion_helper, - ); +); +$rc = GetOptions(%options); # Munge any "either config or getopt, not both" variables my @initial_to = @getopt_to ? @getopt_to : ($no_to ? () : @config_to); @@ -516,7 +536,8 @@ sub config_regexp { my @initial_bcc = @getopt_bcc ? @getopt_bcc : ($no_bcc ? () : @config_bcc); usage() if $help; -completion_helper() if $git_completion_helper; +my %all_options = (%options, %dump_aliases_options, %identity_options); +completion_helper(\%all_options) if $git_completion_helper; unless ($rc) { usage(); } diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 11573936d5..a4faf64184 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2139,6 +2139,9 @@ test_expect_success PERL 'send-email' ' --cover-from-description=Z --cover-letter Z EOF + test_completion "git send-email --val" <<-\EOF && + --validate Z + EOF test_completion "git send-email ma" "main " ' From patchwork Thu Oct 7 03:36:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Perrotta X-Patchwork-Id: 12540921 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 AB409C4332F for ; Thu, 7 Oct 2021 03:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A75060F92 for ; Thu, 7 Oct 2021 03:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240037AbhJGDjx (ORCPT ); Wed, 6 Oct 2021 23:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238333AbhJGDjt (ORCPT ); Wed, 6 Oct 2021 23:39:49 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4010BC061753 for ; Wed, 6 Oct 2021 20:37:56 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id z15so3335185qvj.7 for ; Wed, 06 Oct 2021 20:37:56 -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=p5miaebffGepVtspgU2vqqslmRuZ5w1xZvjmaNwSWAk=; b=Pe+Rf5p4B0zpPRDRs34v58e5v0n/mL1iveMikJVZz4nWgoIPY1+6W+c8a1LKanCHYy MRB7zHpzLOJcc9X3/7DmDFfrOVO6M6K2PYwqCKgBsx4f1bqHFa1uAR01vjy2lYVNcLW4 WHMxYtSYeiVuUnjfCeVrVtPTaqOqyE2v59swRHJEbJcbilvWGLcTVkUUj6XnPyVrSFab eBEfwIuQ0rNb5H/wCjXRLFwmUGj9Gt20yTNZ16RpxZYEMx732uP9KT9UQduhr6sVL0Lb nGJmh2eVnbkKj+SzD8H7sCQ18fEyqkiqV08Ob34RJAPAWBIOE0/F509G6erDr4oyUxtQ 7vfg== 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=p5miaebffGepVtspgU2vqqslmRuZ5w1xZvjmaNwSWAk=; b=ROii/ga2uhmM+bnlWphpngVg8IfiK7h5KJ+u+oJLqaUSHnp5AyNclEdXR9DUxYP29v tFfgklM69H0lhk3wPlIjYdA+fiE0audl6vjN4CvrDJkgZmBnjg3zYU6esq5G5pAB5Njd QoiwFs50ErY8TZ/J+zWqB651zbME4BDKby8X+j6lbyTXbgKBHRMA4E0NqDjAkggj9yUA kYN/GGYJBDsyA9J7YXV/SyMVSzC9EnAFRFG3SAlKhuLGS10cDg7JIoL/VnJnHvJHdfV+ HeSpgI7slgPs2xVCNBtPBTNj2W44MfVu7zCQIaltSSVm69/vhvgaNo7Qo1VTeyKEXEh6 6EIg== X-Gm-Message-State: AOAM532oZvI+2sAwdFLliYHBPrbnvBcCdl3h3O4RJEH4KfAVyqpSreET KN3MC/vk8xP/Cj7GoGusVw4= X-Google-Smtp-Source: ABdhPJztJcutQsBmJFC8B68/YSWtrN4PPVyw9b4vPBa+gM2IL2OAMa61wOF6H3dLjmxtXlEGHVpTQA== X-Received: by 2002:a0c:804a:: with SMTP id 68mr583652qva.27.1633577875409; Wed, 06 Oct 2021 20:37:55 -0700 (PDT) Received: from valhalla.. (cpee03f49946310-cm589630b5b38a.cpe.net.cable.rogers.com. [99.250.23.181]) by smtp.gmail.com with ESMTPSA id x6sm13892860qts.79.2021.10.06.20.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 20:37:55 -0700 (PDT) From: Thiago Perrotta To: carenas@gmail.com, gitster@pobox.com, bagasdotme@gmail.com, avarab@gmail.com Cc: Thiago Perrotta , git@vger.kernel.org Subject: [PATCH v6 3/3] send-email docs: add format-patch options Date: Wed, 6 Oct 2021 23:36:52 -0400 Message-Id: <20211007033652.80793-4-tbperrotta@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org git-send-email(1) does not mention that "git format-patch" options are accepted. Augment SYNOPSIS and DESCRIPTION to mention it. Signed-off-by: Thiago Perrotta --- Documentation/git-send-email.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index 3db4eab4ba..41cd8cb424 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -9,7 +9,8 @@ git-send-email - Send a collection of patches as emails SYNOPSIS -------- [verse] -'git send-email' [] ... +'git send-email' [] ... +'git send-email' [] 'git send-email' --dump-aliases @@ -19,7 +20,8 @@ Takes the patches given on the command line and emails them out. Patches can be specified as files, directories (which will send all files in the directory), or directly as a revision list. In the last case, any format accepted by linkgit:git-format-patch[1] can -be passed to git send-email. +be passed to git send-email, as well as options understood by +linkgit:git-format-patch[1]. The header of the email is configurable via command-line options. If not specified on the command line, the user will be prompted with a ReadLine