Merge branch 'pw/rebase-i-merge-segv-fix'

"git rebase -i", when a 'merge <branch>' insn in its todo list
fails, segfaulted, which has been (minimally) corrected.

* pw/rebase-i-merge-segv-fix:
  rebase -i: fix SIGSEGV when 'merge <branch>' fails
  t3430: add conflicting commit
This commit is contained in:
Junio C Hamano
2018-08-20 12:41:33 -07:00
2 changed files with 42 additions and 12 deletions

View File

@ -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;
}