git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 9, 2024, 21:05 UTC
Message-ID
<xmqqplqhbe4o.fsf@gitster.g>
In-Reply-To
<5ad39a07-a2d4-45d2-9b5d-0180cb903801@intel.com>
Jacob Keller <jacob.e.keller@intel.com> 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;
Previous: Jacob KellerNext: Jacob Keller
Message 9 of 10 in “send-email: teach git send-email mode to translate aliases”
  1. 0/3 send-email: teach git send-email mode to translate aliasesJacob Keller, Aug 8, 2024
  2. 1/3 t90001-send-email.sh: fix quoting for mailrc --dump-aliases testJacob Keller, Aug 8, 2024
  3. 2/3 t9001-send-email.sh: update alias list used for pine testJacob Keller, Aug 8, 2024
  4. 3/3 send-email: teach git send-email option to translate aliasesJacob Keller, Aug 8, 2024
  5. Junio C HamanoAug 8, 2024
  6. Jacob KellerAug 9, 2024
  7. Junio C HamanoAug 9, 2024
  8. Jacob KellerAug 9, 2024
  9. Junio C HamanoAug 9, 2024
  10. Jacob KellerAug 10, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.