Avoid doing the "filelist" thing, since "git-apply" picks up the files automatically
[gitweb.git] / mailinfo.c
index 1ca554e92af08481ede5a8deb37f0eea59bafe4c..6c4d5898238704954a0b67b99079193f588795b6 100644 (file)
@@ -10,6 +10,7 @@
 static FILE *cmitmsg, *patchfile;
 
 static char line[1000];
+static char date[1000];
 static char name[1000];
 static char email[1000];
 static char subject[1000];
@@ -78,6 +79,11 @@ static int handle_from(char *line)
        return 1;
 }
 
+static void handle_date(char *line)
+{
+       strcpy(date, line);
+}
+
 static void handle_subject(char *line)
 {
        strcpy(subject, line);
@@ -99,6 +105,11 @@ static void check_line(char *line, int len)
                cont = 0;
                return;
        }
+       if (!memcmp(line, "Date:", 5) && isspace(line[5])) {
+               handle_date(line+6);
+               cont = 0;
+               return;
+       }
        if (!memcmp(line, "Subject:", 8) && isspace(line[8])) {
                handle_subject(line+9);
                cont = 1;
@@ -107,7 +118,7 @@ static void check_line(char *line, int len)
        if (isspace(*line)) {
                switch (cont) {
                case 0:
-                       fprintf(stderr, "I don't do 'From:' line continuations\n");
+                       fprintf(stderr, "I don't do 'Date:' or 'From:' line continuations\n");
                        break;
                case 1:
                        add_subject_line(line);
@@ -170,62 +181,20 @@ static void cleanup_space(char *buf)
        }
 }
 
-/*
- * Hacky hacky. This depends not only on -p1, but on
- * filenames not having some special characters in them,
- * like tilde.
- */
-static void show_filename(char *line)
-{
-       int len;
-       char *name = strchr(line, '/');
-
-       if (!name || !isspace(*line))
-               return;
-       name++;
-       len = 0;
-       for (;;) {
-               unsigned char c = name[len];
-               switch (c) {
-               default:
-                       len++;
-                       continue;
-
-               case 0: case ' ':
-               case '\t': case '\n':
-                       break;
-
-               case '~':
-                       break;
-               }
-               break;
-       }
-       /* remove ".orig" from the end - common patch behaviour */
-       if (len > 5 && !memcmp(name+len-5, ".orig", 5))
-               len -=5;
-       if (!len)
-               return;
-       printf("filename: %.*s\n", len, name);
-}
-
 static void handle_rest(void)
 {
        char *sub = cleanup_subject(subject);
        cleanup_space(name);
+       cleanup_space(date);
        cleanup_space(email);
        cleanup_space(sub);
-       printf("Author: %s\nEmail: %s\nSubject: %s\n\n", name, email, sub);
+       printf("Author: %s\nEmail: %s\nSubject: %s\nDate: %s\n\n", name, email, sub, date);
        FILE *out = cmitmsg;
 
        do {
-               /* Track filename information from the patch.. */
-               if (!memcmp("---", line, 3)) {
+               if (!memcmp("diff -", line, 6) ||
+                   !memcmp("---", line, 3))
                        out = patchfile;
-                       show_filename(line+3);
-               }
-
-               if (!memcmp("+++", line, 3))
-                       show_filename(line+3);
 
                fputs(line, out);
        } while (fgets(line, sizeof(line), stdin) != NULL);