]> asedeno.scripts.mit.edu Git - git.git/blobdiff - commit.c
Merge branch 'maint'
[git.git] / commit.c
index f86fa776c05b27d0e353cc70ee2b49d29a8de2e7..ac24266e935054c6909b8fbd513ffa937e2ae092 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;
        }
 }
 
@@ -656,14 +661,14 @@ static char *replace_encoding_header(char *buf, const char *encoding)
        strbuf_attach(&tmp, buf, strlen(buf), strlen(buf) + 1);
        if (is_encoding_utf8(encoding)) {
                /* we have re-coded to UTF-8; drop the header */
-               strbuf_splice(&tmp, start, len, NULL, 0);
+               strbuf_remove(&tmp, start, len);
        } else {
                /* just replaces XXXX in 'encoding XXXX\n' */
                strbuf_splice(&tmp, start + strlen("encoding "),
                                          len - strlen("encoding \n"),
                                          encoding, strlen(encoding));
        }
-       return tmp.buf;
+       return strbuf_detach(&tmp, NULL);
 }
 
 static char *logmsg_reencode(const struct commit *commit,
@@ -876,9 +881,6 @@ void format_commit_message(const struct commit *commit,
        }
        if (msg[i])
                table[IBODY].value = xstrdup(msg + i);
-       for (i = 0; i < ARRAY_SIZE(table); i++)
-               if (!table[i].value)
-                       interp_set_entry(table, i, "<unknown>");
 
        len = interpolate(sb->buf + sb->len, strbuf_avail(sb),
                                format, table, ARRAY_SIZE(table));