]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin/revert.c
Merge branch 'mg/reset-doc' into maint
[git.git] / builtin / revert.c
index 7f35cc6e1734c4000d8971f808356d0fb344ffc6..4b47ace36b51566acb5b748f679070f02cbbf568 100644 (file)
@@ -102,9 +102,9 @@ struct commit_message {
 static int get_message(const char *raw_message, struct commit_message *out)
 {
        const char *encoding;
-       const char *p, *abbrev, *eol;
+       const char *abbrev, *subject;
+       int abbrev_len, subject_len;
        char *q;
-       int abbrev_len, oneline_len;
 
        if (!raw_message)
                return -1;
@@ -125,27 +125,17 @@ static int get_message(const char *raw_message, struct commit_message *out)
        abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
        abbrev_len = strlen(abbrev);
 
-       /* Find beginning and end of commit subject. */
-       p = out->message;
-       while (*p && (*p != '\n' || p[1] != '\n'))
-               p++;
-       if (*p) {
-               p += 2;
-               for (eol = p + 1; *eol && *eol != '\n'; eol++)
-                       ; /* do nothing */
-       } else
-               eol = p;
-       oneline_len = eol - p;
+       subject_len = find_commit_subject(out->message, &subject);
 
        out->parent_label = xmalloc(strlen("parent of ") + abbrev_len +
-                             strlen("... ") + oneline_len + 1);
+                             strlen("... ") + subject_len + 1);
        q = out->parent_label;
        q = mempcpy(q, "parent of ", strlen("parent of "));
        out->label = q;
        q = mempcpy(q, abbrev, abbrev_len);
        q = mempcpy(q, "... ", strlen("... "));
        out->subject = q;
-       q = mempcpy(q, p, oneline_len);
+       q = mempcpy(q, subject, subject_len);
        *q = '\0';
        return 0;
 }
@@ -326,6 +316,13 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
        index_fd = hold_locked_index(&index_lock, 1);
 
        read_cache();
+
+       /*
+        * NEEDSWORK: cherry-picking between branches with
+        * different end-of-line normalization is a pain;
+        * plumb in an option to set o.renormalize?
+        * (or better: arbitrary -X options)
+        */
        init_merge_options(&o);
        o.ancestor = base ? base_label : "(empty tree)";
        o.branch1 = "HEAD";