Hi Junio,

On Thu, 12 Jan 2017, Junio C Hamano wrote:

> Johannes Schindelin <johannes.schinde...@gmx.de> writes:
> 
> > +static int make_patch(struct commit *commit, struct replay_opts *opts)
> > +{
> > +   struct strbuf buf = STRBUF_INIT;
> > +   struct rev_info log_tree_opt;
> > +   const char *subject, *p;
> > +   int res = 0;
> > +
> > +   p = short_commit_name(commit);
> > +   if (write_message(p, strlen(p), rebase_path_stopped_sha(), 1) < 0)
> > +           return -1;
> > +
> > +   strbuf_addf(&buf, "%s/patch", get_dir(opts));
> > +   memset(&log_tree_opt, 0, sizeof(log_tree_opt));
> > +   init_revisions(&log_tree_opt, NULL);
> > +   log_tree_opt.abbrev = 0;
> > +   log_tree_opt.diff = 1;
> > +   log_tree_opt.diffopt.output_format = DIFF_FORMAT_PATCH;
> > +   log_tree_opt.disable_stdin = 1;
> > +   log_tree_opt.no_commit_id = 1;
> > +   log_tree_opt.diffopt.file = fopen(buf.buf, "w");
> > +   log_tree_opt.diffopt.use_color = GIT_COLOR_NEVER;
> > +   if (!log_tree_opt.diffopt.file)
> > +           res |= error_errno(_("could not open '%s'"), buf.buf);
> > +   else {
> > +           res |= log_tree_commit(&log_tree_opt, commit);
> > +           fclose(log_tree_opt.diffopt.file);
> > +   }
> > +   strbuf_reset(&buf);
> > +
> > +   strbuf_addf(&buf, "%s/message", get_dir(opts));
> > +   if (!file_exists(buf.buf)) {
> > +           const char *commit_buffer = get_commit_buffer(commit, NULL);
> > +           find_commit_subject(commit_buffer, &subject);
> > +           res |= write_message(subject, strlen(subject), buf.buf, 1);
> > +           unuse_commit_buffer(commit, commit_buffer);
> > +   }
> > +   strbuf_release(&buf);
> > +
> > +   return res;
> > +}
> 
> Unlike the scripted version, where a merge is shown with "diff --cc"
> and a root commit is shown as "Root commit", this only deals with a
> single-parent commit.

Indeed. The reason is that we never encounter a merge commit (as we
explicitly do not handle --preserve-merges) nor root commits (as we
explicitly do not handle --root)

Ciao,
Johannes

Reply via email to