path: root/tools/mailinfo.c
diff options
authorJunio C Hamano <>2005-07-22 23:04:34 (GMT)
committerLinus Torvalds <>2005-07-22 23:29:28 (GMT)
commit44d2eb51b1c360c0337429f9a4a4f95d26d047eb (patch)
tree0fa4a95b0b9b0f02597e70cfcc0d61676bb55e8d /tools/mailinfo.c
parent3727531899aecac02c50c6580e84c627c25fcaa6 (diff)
[PATCH] git-format-patch-script and mailinfo updates.
- avoid duplicating [PATCH] in the commit message body if the original commit has it already (happens for commits done from mails via applymbox). - check if the commit author is different from the one who is running the script, and emit an appropriate "From:" and "Date: " lines to the output. - with '--date', emit "Date: " line to preserve the original author date even for the user's own commit. - teach mailinfo to grok not just "From: " but "Date: ". The patch e-mail output by format-patch starts with the first line from the original commit message, prefixed with [PATCH], and optionally a From: line if you are reformatting a patch obtained from somebody else, a Date: line from the original commit if (1) --date is specified or (2) for somebody else's patch, and the rest of the commit message body. Expected use of this is to move the title line from the commit to Subject: when sending it via an e-mail, and leave the From: and the Date: lines as the first lines of your message. The mailinfo command has been changed to read Date: (in addition to From: it already understands) and do sensible things when running applymbox. Signed-off-by: Junio C Hamano <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'tools/mailinfo.c')
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/mailinfo.c b/tools/mailinfo.c
index ae279bf..4dcc099 100644
--- a/tools/mailinfo.c
+++ b/tools/mailinfo.c
@@ -220,8 +220,9 @@ static int eatspace(char *line)
static void handle_body(void)
int has_from = 0;
+ int has_date = 0;
- /* First line of body can be a From: */
+ /* First lines of body can have From: and Date: */
while (fgets(line, sizeof(line), stdin) != NULL) {
int len = eatspace(line);
if (!len)
@@ -232,6 +233,13 @@ static void handle_body(void)
+ if (!memcmp("Date:", line, 5) && isspace(line[5])) {
+ if (!has_date) {
+ handle_date(line+6);
+ has_date = 1;
+ continue;
+ }
+ }
line[len] = '\n';