| 2261 | } |
| 2262 | |
| 2263 | static int do_pick_commit(struct repository *r, |
| 2264 | struct todo_item *item, |
| 2265 | struct replay_opts *opts, |
| 2266 | int final_fixup, int *check_todo) |
| 2267 | { |
| 2268 | struct replay_ctx *ctx = opts->ctx; |
| 2269 | unsigned int flags = should_edit(opts) ? EDIT_MSG : 0; |
| 2270 | const char *msg_file = should_edit(opts) ? NULL : git_path_merge_msg(r); |
| 2271 | struct object_id head; |
| 2272 | struct commit *base, *next, *parent; |
| 2273 | const char *base_label, *next_label, *reflog_action; |
| 2274 | char *author = NULL; |
| 2275 | struct commit_message msg = { NULL, NULL, NULL, NULL }; |
| 2276 | int res, unborn = 0, reword = 0, allow, drop_commit; |
| 2277 | enum todo_command command = item->command; |
| 2278 | struct commit *commit = item->commit; |
| 2279 | |
| 2280 | if (is_rebase_i(opts)) |
| 2281 | reflog_action = reflog_message( |
| 2282 | opts, command_to_string(item->command), NULL); |
| 2283 | else |
| 2284 | reflog_action = sequencer_reflog_action(opts); |
| 2285 | |
| 2286 | if (opts->no_commit) { |
| 2287 | /* |
| 2288 | * We do not intend to commit immediately. We just want to |
| 2289 | * merge the differences in, so let's compute the tree |
| 2290 | * that represents the "current" state for the merge machinery |
| 2291 | * to work on. |
| 2292 | */ |
| 2293 | if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL)) |
| 2294 | return error(_("your index file is unmerged.")); |
| 2295 | } else { |
| 2296 | unborn = repo_get_oid(r, "HEAD", &head); |
| 2297 | /* Do we want to generate a root commit? */ |
| 2298 | if (is_pick_or_similar(command) && opts->have_squash_onto && |
| 2299 | oideq(&head, &opts->squash_onto)) { |
| 2300 | if (is_fixup(command)) |
| 2301 | return error(_("cannot fixup root commit")); |
| 2302 | flags |= CREATE_ROOT_COMMIT; |
| 2303 | unborn = 1; |
| 2304 | } else if (unborn) |
| 2305 | oidcpy(&head, the_hash_algo->empty_tree); |
| 2306 | if (index_differs_from(r, unborn ? empty_tree_oid_hex(the_repository->hash_algo) : "HEAD", |
| 2307 | NULL, 0)) |
| 2308 | return error_dirty_index(r, opts); |
| 2309 | } |
| 2310 | discard_index(r->index); |
| 2311 | |
| 2312 | if (!commit->parents) |
| 2313 | parent = NULL; |
| 2314 | else if (commit->parents->next) { |
| 2315 | /* Reverting or cherry-picking a merge commit */ |
| 2316 | int cnt; |
| 2317 | struct commit_list *p; |
| 2318 | |
| 2319 | if (!opts->mainline) |
| 2320 | return error(_("commit %s is a merge but no -m option was given."), |
no test coverage detected