summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorDuy Nguyen <pclouds@gmail.com>2018-11-03 06:03:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-06 04:22:30 (GMT)
commit13374987dd889858758afef458bd8a8cbf15bb4d (patch)
treeb3f47bff1bc37a7230d158b2c8d436fc068f19b9 /git-send-email.perl
parentc4df23f7927d8d00e666a3c8d1b3375f1dc8a3c1 (diff)
downloadgit-13374987dd889858758afef458bd8a8cbf15bb4d.zip
git-13374987dd889858758afef458bd8a8cbf15bb4d.tar.gz
git-13374987dd889858758afef458bd8a8cbf15bb4d.tar.bz2
completion: use __gitcomp_builtin for format-patch
This helps format-patch gain completion for a couple new options, notably --range-diff. Since send-email completion relies on $__git_format_patch_options which is now reduced, we need to do something not to regress send-email completion. The workaround here is implement --git-completion-helper in send-email.perl just as a bridge to "format-patch --git-completion-helper". This is enough to use __gitcomp_builtin on send-email (to take advantage of caching). In the end, send-email.perl can probably reuse the same info it passes to GetOptions() to generate full --git-completion-helper output so that we don't need to keep track of its options in git-completion.bash anymore. But that's something for another boring day. Helped-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl8
1 files changed, 8 insertions, 0 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 2be5dac..ed0714e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -119,6 +119,11 @@ EOT
exit(1);
}
+sub completion_helper {
+ print Git::command('format-patch', '--git-completion-helper');
+ exit(0);
+}
+
# most mail servers generate the Date: header, but not all...
sub format_2822_time {
my ($time) = @_;
@@ -311,6 +316,7 @@ $SIG{INT} = \&signal_handler;
# needing, first, from the command line:
my $help;
+my $git_completion_helper;
my $rc = GetOptions("h" => \$help,
"dump-aliases" => \$dump_aliases);
usage() unless $rc;
@@ -373,9 +379,11 @@ $rc = GetOptions(
"no-xmailer" => sub {$use_xmailer = 0},
"batch-size=i" => \$batch_size,
"relogin-delay=i" => \$relogin_delay,
+ "git-completion-helper" => \$git_completion_helper,
);
usage() if $help;
+completion_helper() if $git_completion_helper;
unless ($rc) {
usage();
}