]> asedeno.scripts.mit.edu Git - git.git/blobdiff - commit.c
send-email: add transfer encoding header with content-type
[git.git] / commit.c
index d11941c7f4cb6bf303ff7750c15a2fac753c4518..1fbdd2d51b8e798ac73c4b020f8fa47b1d6fb168 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -441,17 +441,22 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
 
 void clear_commit_marks(struct commit *commit, unsigned int mark)
 {
-       struct commit_list *parents;
+       while (commit) {
+               struct commit_list *parents;
 
-       commit->object.flags &= ~mark;
-       parents = commit->parents;
-       while (parents) {
-               struct commit *parent = parents->item;
+               if (!(mark & commit->object.flags))
+                       return;
 
-               /* Have we already cleared this? */
-               if (mark & parent->object.flags)
-                       clear_commit_marks(parent, mark);
-               parents = parents->next;
+               commit->object.flags &= ~mark;
+
+               parents = commit->parents;
+               if (!parents)
+                       return;
+
+               while ((parents = parents->next))
+                       clear_commit_marks(parents->item, mark);
+
+               commit = commit->parents->item;
        }
 }
 
@@ -585,7 +590,7 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
                break;
        case CMIT_FMT_EMAIL:
                ret += sprintf(buf + ret, "Date: %s\n",
-                              show_rfc2822_date(time, tz));
+                              show_date(time, tz, DATE_RFC2822));
                break;
        case CMIT_FMT_FULLER:
                ret += sprintf(buf + ret, "%sDate: %s\n", what,
@@ -721,7 +726,10 @@ static char *logmsg_reencode(const struct commit *commit,
        encoding = get_header(commit, "encoding");
        use_encoding = encoding ? encoding : utf8;
        if (!strcmp(use_encoding, output_encoding))
-               out = xstrdup(commit->buffer);
+               if (encoding) /* we'll strip encoding header later */
+                       out = xstrdup(commit->buffer);
+               else
+                       return NULL; /* nothing to do */
        else
                out = reencode_string(commit->buffer,
                                      output_encoding, use_encoding);
@@ -778,9 +786,9 @@ static void fill_person(struct interp *table, const char *msg, int len)
                        tz = -tz;
        }
 
-       interp_set_entry(table, 2, show_date(date, tz, 0));
-       interp_set_entry(table, 3, show_rfc2822_date(date, tz));
-       interp_set_entry(table, 4, show_date(date, tz, 1));
+       interp_set_entry(table, 2, show_date(date, tz, DATE_NORMAL));
+       interp_set_entry(table, 3, show_date(date, tz, DATE_RFC2822));
+       interp_set_entry(table, 4, show_date(date, tz, DATE_RELATIVE));
        interp_set_entry(table, 6, show_date(date, tz, DATE_ISO8601));
 }