Merge branch 'nd/cherry-pick-quit-fix'
[gitweb.git] / sequencer.c
index b8f274bdec7aca3b93b13f985b6083f95ea5cfac..65d371c7461c1f8098e0334532ae7804c30f66d6 100644 (file)
@@ -1253,7 +1253,7 @@ static int try_to_commit(struct strbuf *msg, const char *author,
                commit_list_insert(current_head, &parents);
        }
 
-       if (write_cache_as_tree(&tree, 0, NULL)) {
+       if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL)) {
                res = error(_("git write-tree failed to write a tree"));
                goto out;
        }
@@ -1552,13 +1552,13 @@ static int update_squash_messages(enum todo_command command,
                unlink(rebase_path_fixup_msg());
                strbuf_addf(&buf, "\n%c ", comment_line_char);
                strbuf_addf(&buf, _("This is the commit message #%d:"),
-                           ++opts->current_fixup_count);
+                           ++opts->current_fixup_count + 1);
                strbuf_addstr(&buf, "\n\n");
                strbuf_addstr(&buf, body);
        } else if (command == TODO_FIXUP) {
                strbuf_addf(&buf, "\n%c ", comment_line_char);
                strbuf_addf(&buf, _("The commit message #%d will be skipped:"),
-                           ++opts->current_fixup_count);
+                           ++opts->current_fixup_count + 1);
                strbuf_addstr(&buf, "\n\n");
                strbuf_add_commented_lines(&buf, body, strlen(body));
        } else
@@ -1639,7 +1639,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
                 * that represents the "current" state for merge-recursive
                 * to work on.
                 */
-               if (write_cache_as_tree(&head, 0, NULL))
+               if (write_index_as_tree(&head, &the_index, get_index_file(), 0, NULL))
                        return error(_("your index file is unmerged."));
        } else {
                unborn = get_oid("HEAD", &head);
@@ -2610,8 +2610,13 @@ static int error_with_patch(struct commit *commit,
        const char *subject, int subject_len,
        struct replay_opts *opts, int exit_code, int to_amend)
 {
-       if (make_patch(commit, opts))
-               return -1;
+       if (commit) {
+               if (make_patch(commit, opts))
+                       return -1;
+       } else if (copy_file(rebase_path_message(),
+                            git_path_merge_msg(the_repository), 0666))
+               return error(_("unable to copy '%s' to '%s'"),
+                            git_path_merge_msg(the_repository), rebase_path_message());
 
        if (to_amend) {
                if (intend_to_amend())
@@ -2626,9 +2631,18 @@ static int error_with_patch(struct commit *commit,
                          "\n"
                          "  git rebase --continue\n"),
                        gpg_sign_opt_quoted(opts));
-       } else if (exit_code)
-               fprintf_ln(stderr, _("Could not apply %s... %.*s"),
-                       short_commit_name(commit), subject_len, subject);
+       } else if (exit_code) {
+               if (commit)
+                       fprintf_ln(stderr, _("Could not apply %s... %.*s"),
+                                  short_commit_name(commit), subject_len, subject);
+               else
+                       /*
+                        * We don't have the hash of the parent so
+                        * just print the line from the todo file.
+                        */
+                       fprintf_ln(stderr, _("Could not merge %.*s"),
+                                  subject_len, subject);
+       }
 
        return exit_code;
 }