Merge branch 'svn-fe' of git://repo.or.cz/git/jrn into jn/svn-fe
[gitweb.git] / builtin / revert.c
index 6d520aee7d6d8d0f5426a3ddd0bccfea0ec90346..0d8020cf640e1abe6898308a1656446b327c83f4 100644 (file)
@@ -700,16 +700,16 @@ static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
                struct replay_opts *opts)
 {
        struct commit_list *cur = NULL;
-       struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
        const char *sha1_abbrev = NULL;
        const char *action_str = opts->action == REVERT ? "revert" : "pick";
+       const char *subject;
+       int subject_len;
 
        for (cur = todo_list; cur; cur = cur->next) {
                sha1_abbrev = find_unique_abbrev(cur->item->object.sha1, DEFAULT_ABBREV);
-               if (get_message(cur->item, &msg))
-                       return error(_("Cannot get commit message for %s"), sha1_abbrev);
-               strbuf_addf(buf, "%s %s %s\n", action_str, sha1_abbrev, msg.subject);
-               free_message(&msg);
+               subject_len = find_commit_subject(cur->item->buffer, &subject);
+               strbuf_addf(buf, "%s %s %.*s\n", action_str, sha1_abbrev,
+                       subject_len, subject);
        }
        return 0;
 }
@@ -719,18 +719,24 @@ static struct commit *parse_insn_line(char *bol, char *eol, struct replay_opts *
        unsigned char commit_sha1[20];
        enum replay_action action;
        char *end_of_object_name;
-       int saved, status;
+       int saved, status, padding;
 
-       if (!prefixcmp(bol, "pick ")) {
+       if (!prefixcmp(bol, "pick")) {
                action = CHERRY_PICK;
-               bol += strlen("pick ");
-       } else if (!prefixcmp(bol, "revert ")) {
+               bol += strlen("pick");
+       } else if (!prefixcmp(bol, "revert")) {
                action = REVERT;
-               bol += strlen("revert ");
+               bol += strlen("revert");
        } else
                return NULL;
 
-       end_of_object_name = bol + strcspn(bol, " \n");
+       /* Eat up extra spaces/ tabs before object name */
+       padding = strspn(bol, " \t");
+       if (!padding)
+               return NULL;
+       bol += padding;
+
+       end_of_object_name = bol + strcspn(bol, " \t\n");
        saved = *end_of_object_name;
        *end_of_object_name = '\0';
        status = get_sha1(bol, commit_sha1);
@@ -899,7 +905,7 @@ static int rollback_single_pick(void)
        if (!file_exists(git_path("CHERRY_PICK_HEAD")) &&
            !file_exists(git_path("REVERT_HEAD")))
                return error(_("no cherry-pick or revert in progress"));
-       if (!resolve_ref("HEAD", head_sha1, 0, NULL))
+       if (read_ref_full("HEAD", head_sha1, 0, NULL))
                return error(_("cannot resolve HEAD"));
        if (is_null_sha1(head_sha1))
                return error(_("cannot abort from a branch yet to be born"));