git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/3] git-send-email options and completion improvements
@ 2021-08-02 20:49 Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 1/3] Print newline for git-send-email --git-completion-helper Thiago Perrotta
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thiago Perrotta @ 2021-08-02 20:49 UTC (permalink / raw)
  To: git; +Cc: Thiago Perrotta

This patch makes git-send-email completion (bash, zsh) uniform,
centralizing the completion options on git-send-email.perl instead of
git-completion.bash

The overall result is that git send-email --git-completion-helper now
properly emits send-email specific options. Previously, it was only
emitting format-patch flags.

Additionally there's a sentence in git-send-email(1) to explicitly
mention that format-patch options can also be passed to it. Currently
it's not obvious this is the case from the man page alone.

Thiago Perrotta (3):
  Print newline for git-send-email --git-completion-helper.
  Move bash git-send-email completions to original script.
  Expand git-send-email docs to mention format-patch options.

 Documentation/git-send-email.txt       |  2 ++
 contrib/completion/git-completion.bash | 11 +-------
 git-send-email.perl                    | 35 ++++++++++++++++++++++++++
 t/t9902-completion.sh                  |  3 +++
 4 files changed, 41 insertions(+), 10 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] Print newline for git-send-email --git-completion-helper.
  2021-08-02 20:49 [PATCH 0/3] git-send-email options and completion improvements Thiago Perrotta
@ 2021-08-02 20:49 ` Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 2/3] Move bash git-send-email completions to original script Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 3/3] Expand git-send-email docs to mention format-patch options Thiago Perrotta
  2 siblings, 0 replies; 4+ messages in thread
From: Thiago Perrotta @ 2021-08-02 20:49 UTC (permalink / raw)
  To: git; +Cc: Thiago Perrotta

Rationale: All git built-in commands print a newline upon upon git <cmd>
--git-completion-helper. Therefore git-send-email should follow suit for
consistency.

Signed-off-by: Thiago Perrotta <tbperrotta@gmail.com>
---
 git-send-email.perl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/git-send-email.perl b/git-send-email.perl
index e65d969..e991bf3 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -115,6 +115,7 @@ sub usage {
 
 sub completion_helper {
     print Git::command('format-patch', '--git-completion-helper');
+    print "\n";
     exit(0);
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] Move bash git-send-email completions to original script.
  2021-08-02 20:49 [PATCH 0/3] git-send-email options and completion improvements Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 1/3] Print newline for git-send-email --git-completion-helper Thiago Perrotta
@ 2021-08-02 20:49 ` Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 3/3] Expand git-send-email docs to mention format-patch options Thiago Perrotta
  2 siblings, 0 replies; 4+ messages in thread
From: Thiago Perrotta @ 2021-08-02 20:49 UTC (permalink / raw)
  To: git; +Cc: Thiago Perrotta

As far as bash-completion is concerned, this refactoring is a no-op.

However, this improves `git send-email --git-completion-helper`, which
was previously printing only `git format-patch` flags, to print
send-email specific flags as well.

Add a completion test for --validate which is a send-email specific
option.

Signed-off-by: Thiago Perrotta <tbperrotta@gmail.com>
---
 contrib/completion/git-completion.bash | 11 +--------
 git-send-email.perl                    | 34 ++++++++++++++++++++++++++
 t/t9902-completion.sh                  |  3 +++
 3 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 4bdd27d..1b73a4d 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 e991bf3..eec78d7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -114,6 +114,40 @@ sub usage {
 }
 
 sub completion_helper {
+    my @send_email_flags = qw/
+    --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
+    /;
+    print "@send_email_flags";
     print Git::command('format-patch', '--git-completion-helper');
     print "\n";
     exit(0);
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 1157393..a4faf64 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 "
 '
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] Expand git-send-email docs to mention format-patch options.
  2021-08-02 20:49 [PATCH 0/3] git-send-email options and completion improvements Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 1/3] Print newline for git-send-email --git-completion-helper Thiago Perrotta
  2021-08-02 20:49 ` [PATCH 2/3] Move bash git-send-email completions to original script Thiago Perrotta
@ 2021-08-02 20:49 ` Thiago Perrotta
  2 siblings, 0 replies; 4+ messages in thread
From: Thiago Perrotta @ 2021-08-02 20:49 UTC (permalink / raw)
  To: git; +Cc: Thiago Perrotta

Currently git-send-email(1) does not make it explicit format-patch
options are accepted.

Signed-off-by: Thiago Perrotta <tbperrotta@gmail.com>
---
 Documentation/git-send-email.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 3db4eab..05dd8de 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -42,6 +42,8 @@ and the "Subject:" of the message as the second line.
 OPTIONS
 -------
 
+Options from linkgit:git-format-patch[1] are also accepted.
+
 Composing
 ~~~~~~~~~
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-02 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 20:49 [PATCH 0/3] git-send-email options and completion improvements Thiago Perrotta
2021-08-02 20:49 ` [PATCH 1/3] Print newline for git-send-email --git-completion-helper Thiago Perrotta
2021-08-02 20:49 ` [PATCH 2/3] Move bash git-send-email completions to original script Thiago Perrotta
2021-08-02 20:49 ` [PATCH 3/3] Expand git-send-email docs to mention format-patch options Thiago Perrotta

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).