Subject: Re: [PATCH 3/3] send-email: teach git send-email option to translate aliases

From: Junio C Hamano <[email-masked]>
Date: Fri, 09 Aug 2024 14:05:59 -0700

Jacob Keller <[email-masked]> writes:

> We could try to implement scanning for options ourselves, but I wouldn't
> want to break things like "--" to make it treat potential option-looking
> fields as aliases...

The appoach --dump-aliases takes is already broken with respect to
options that take or do not take an argument, if you really want to
scan, understand, and skip irrelevant options anyway, no?  The
separate, trimmed down %dump_aliases_options map cannot help you to
tell from the command line "git cmd --translate --foo bar" if
skipping just "--foo" gives you the alias-to-be-expanded "bar", or
"--foo" takes an argument that is "bar" and there is no alias left.

So I do not quite know how involved you want to go, but naïvely, I
would have thought something along the lines of illustration below
is sufficient.

 git-send-email.perl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git c/git-send-email.perl w/git-send-email.perl
index 72044e5ef3..a7239698f8 100755
--- c/git-send-email.perl
+++ w/git-send-email.perl
@@ -747,6 +747,20 @@ sub is_format_patch_arg {
 	}
 }
 
+# Now, if the user who wants --translate knows that the command will not
+# send any mails and the remainder of the command line are aliases to be
+# expanded, the user wouldn't have given useless other options to trigger
+# any of the executable code before this point (like $suppress_cc{} handling)
+# that would be wasted.  So we just see if --translate is given and deal
+# with it here.
+
+if ($translate_alias) {
+	for (@ARGV) {
+		print "$_ => $aliases{$_}\n";
+	}
+	exit(0);
+}
+
 # Now that all the defaults are set, process the rest of the command line
 # arguments and collect up the files that need to be processed.
 my @rev_list_opts;