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

[PATCH 2/5] add the ability to select more email header fields to output

From
DZDon Zickus <dzickus@redhat.com>
Date
Mar 14, 2007, 20:12 UTC
Message-ID
<11739031471426-git-send-email-dzickus@redhat.com>
In-Reply-To
<11739031463211-git-send-email-dzickus@redhat.com>

This is useful when scripts need more than just the basic email headers to parse. By specifying the "-x=" option, one can search and output any header field they want.

Signed-off-by: Don Zickus <dzickus@redhat.com>
---
 builtin-mailinfo.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index dacdf77..dd0f563 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -856,11 +856,12 @@ int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
 }
 
 static const char mailinfo_usage[] =
-	"git-mailinfo [-k] [-u | --encoding=<encoding>] msg patch <mail >info";
+	"git-mailinfo [-k] [-u | --encoding=<encoding>] [-x=<field>] msg patch <mail >info";
 
 int cmd_mailinfo(int argc, const char **argv, const char *prefix)
 {
 	const char *def_charset;
+	int top;
 
 	/* NEEDSWORK: might want to do the optional .git/ directory
 	 * discovery
@@ -870,6 +871,8 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
 	def_charset = (git_commit_encoding ? git_commit_encoding : "utf-8");
 	metainfo_charset = def_charset;
 
+	for (top=0; header[top]; top++){ ; }
+
 	while (1 < argc && argv[1][0] == '-') {
 		if (!strcmp(argv[1], "-k"))
 			keep_subject = 1;
@@ -879,7 +882,10 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
 			metainfo_charset = NULL;
 		else if (!prefixcmp(argv[1], "--encoding="))
 			metainfo_charset = argv[1] + 11;
-		else
+		else if (!prefixcmp(argv[1], "-x=")) {
+			header[top] = xmalloc(256*sizeof(char));
+			strncpy(header[top++], argv[1]+3, 256);
+		} else
 			usage(mailinfo_usage);
 		argc--; argv++;
 	}
-- 
1.5.0.2.211.g2ca9-dirty
Previous: Don ZickusNext: Don Zickus
Message 4 of 8 in “git-mailinfo fixes/features v3”
  1. Don ZickusMar 14, 2007
  2. 1/5 builtin-mailinfo.c infrastrcture changesDon Zickus, Mar 14, 2007
  3. Don ZickusMar 15, 2007
  4. 2/5 add the ability to select more email header fields to outputDon Zickus, Mar 14, 2007
  5. Don ZickusMar 15, 2007
  6. 3/5 restrict the patch filteringDon Zickus, Mar 14, 2007
  7. 4/5 Add a couple more test cases to the suite.Don Zickus, Mar 14, 2007
  8. 5/5 fix a utf8 issue in t5100/patch005Don Zickus, Mar 14, 2007

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.