Merge branch 'pw/rebase-i-merge-segv-fix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 19:41:33 +0000 (12:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Aug 2018 19:41:33 +0000 (12:41 -0700)
"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

1  2 
sequencer.c
t/t3430-rebase-merges.sh
diff --cc sequencer.c
index 2db52fe8004b3147febace813ac6333fe8f44c55,df49199175e8b8d47c19fcd4f211ebe0f26b2de1..65d371c7461c1f8098e0334532ae7804c30f66d6
@@@ -2610,25 -2590,37 +2610,39 @@@ static int error_with_patch(struct comm
        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(), 0666))
++      } 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(), rebase_path_message());
++                           git_path_merge_msg(the_repository), rebase_path_message());
  
        if (to_amend) {
                if (intend_to_amend())
                        return -1;
  
 -              fprintf(stderr, "You can amend the commit now, with\n"
 -                      "\n"
 -                      "  git commit --amend %s\n"
 -                      "\n"
 -                      "Once you are satisfied with your changes, run\n"
 -                      "\n"
 -                      "  git rebase --continue\n", gpg_sign_opt_quoted(opts));
 +              fprintf(stderr,
 +                      _("You can amend the commit now, with\n"
 +                        "\n"
 +                        "  git commit --amend %s\n"
 +                        "\n"
 +                        "Once you are satisfied with your changes, run\n"
 +                        "\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(stderr, "Could not apply %s... %.*s\n",
 -                              short_commit_name(commit),
 -                              subject_len, subject);
++                      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(stderr, "Could not merge %.*s\n",
 -                              subject_len, subject);
++                      fprintf_ln(stderr, _("Could not merge %.*s"),
++                                 subject_len, subject);
+       }
  
        return exit_code;
  }
Simple merge