Skip to contentSkip to conversation

send-email: add option -h

PATCH In review Clemens Buchacher 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 send-email: add option -h

Most other git commands print a synopsis when passed -h. Make send-email do the same.

---
 git-send-email.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
git-send-email.perl +4 -1
index 98ab33a..4ac6931 100755
@@ -275,7 +275,9 @@ $SIG{INT}  = \&signal_handler;
 # Begin by accumulating all the variables (defined above), that we will end up
 # needing, first, from the command line:
 
-my $rc = GetOptions("sender|from=s" => \$sender,
+my $help;
+my $rc = GetOptions("help|H|h" => \$help,
+		    "sender|from=s" => \$sender,
                     "in-reply-to=s" => \$initial_reply_to,
 		    "subject=s" => \$initial_subject,
 		    "to=s" => \@initial_to,
@@ -313,6 +315,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "force" => \$force,
 	 );
 
+usage() if $help;
 unless ($rc) {
     usage();
 }
Signature · 1 line
1.7.6.1
#1 lore raw

git-send-email.perl $SIG{INT} = \&signal_handler; · line 279

Quoted 7 lines · Clemens Buchacher

Most other git commands print a synopsis when passed -h. Make send-email do the same.

...

git-send-email.perl +2 -0
+my $help;
+my $rc = GetOptions("help|H|h" => \$help,

I do not think what the patch aims to do is wrong per-se, but

 $ git send-email --help

already shows the full documentation, and I find it is misleading to say "help|H|h" here to pretend as if a long-help is triggered with this command. For that matter, do we have any other place that accept -H for help?

IOW, shouldn't this line be this instead?

Quoted 1 line

+my $rc = GetOptions("h" => \$help,

#2 lore raw
Quoted 12 lines · Junio C Hamano

Review

Quoted 7 lines · Clemens Buchacher

Most other git commands print a synopsis when passed -h. Make send-email do the same.

...

(quoted diff) +2 -0
+my $help;
+my $rc = GetOptions("help|H|h" => \$help,

I do not think what the patch aims to do is wrong per-se, but

Quoted 10 lines
 $ git send-email --help

already shows the full documentation, and I find it is misleading to say "help|H|h" here to pretend as if a long-help is triggered with this command. For that matter, do we have any other place that accept -H for help?

IOW, shouldn't this line be this instead?

Quoted 1 line

+my $rc = GetOptions("h" => \$help,

Sure. I was just copy-pasting from git-svn.perl. And in fact I _was_ confused by the fact that it also seemed to allow --help, but in fact did not handle that case any different.

Just found a few more places, so how about this on top?

-->8--
From: Clemens Buchacher <[email protected]>
Date: Tue, 6 Sep 2011 08:27:13 +0200
Subject: [PATCH] use -h for synopsis and --help for manpage consistently

The "git cmd --help" syntax is translated into "git help cmd" by git.c. Do not pretend to handle such cases in any individual commands.

---
 git-cvsserver.perl  |    4 ++--
 git-pull.sh         |    2 +-
 git-send-email.perl |    2 +-
 git-svn.perl        |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
git-cvsserver.perl +2 -2
index 1b8bff2..6c5185e 100755
@@ -109,14 +109,14 @@ my $usage =
     "    --strict-paths      : Don't allow recursing into subdirectories\n".
     "    --export-all        : Don't check for gitcvs.enabled in config\n".
     "    --version, -V       : Print version information and exit\n".
-    "    --help, -h, -H      : Print usage information and exit\n".
+    "    -h                  : Print usage information and exit\n".
     "\n".
     "<directory> ... is a list of allowed directories. If no directories\n".
     "are given, all are allowed. This is an additional restriction, gitcvs\n".
     "access still needs to be enabled by the gitcvs.enabled config option.\n".
     "Alternately, one directory may be specified in GIT_CVSSERVER_ROOT.\n";
 
-my @opts = ( 'help|h|H', 'version|V',
+my @opts = ( 'h', 'version|V',
 	     'base-path=s', 'strict-paths', 'export-all' );
 GetOptions( $state, @opts )
     or die $usage;
git-pull.sh +1 -1
index 63da37b..f08372a 100755
@@ -120,7 +120,7 @@ do
 	--d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
 		dry_run=--dry-run
 		;;
-	-h|--h|--he|--hel|--help|--help-|--help-a|--help-al|--help-all)
+	-h)
 		usage
 		;;
 	*)
git-send-email.perl +1 -1
index 4ac6931..734356a 100755
@@ -276,7 +276,7 @@ $SIG{INT}  = \&signal_handler;
 # needing, first, from the command line:
 
 my $help;
-my $rc = GetOptions("help|H|h" => \$help,
+my $rc = GetOptions("h" => \$help,
 		    "sender|from=s" => \$sender,
                     "in-reply-to=s" => \$initial_reply_to,
 		    "subject=s" => \$initial_subject,
git-svn.perl +1 -1
index 89f83fd..a019f55 100755
@@ -294,7 +294,7 @@ read_git_config(\%opts);
 if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
 	Getopt::Long::Configure('pass_through');
 }
-my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
+my $rv = GetOptions(%opts, 'h' => \$_help, 'version|V' => \$_version,
                     'minimize-connections' => \$Git::SVN::Migration::_minimize,
                     'id|i=s' => \$Git::SVN::default_ref_id,
                     'svn-remote|remote|R=s' => sub {
Signature · 1 line
1.7.6.1
#3 lore raw
Quoted 1 line · Clemens Buchacher

Just found a few more places, so how about this on top?

Yeah, something like that, except for git-send-email bits on side instead, perhaps. There is no poing in adding a known bad version first and then fix with a follow-up ;-).

Also I notice that "git-pull" parses "--help-all" but does not seem to do anything useful (it gives the one-line "Usage: " message and exits with 0) which probably deserves a patch separate from other commands.