Subject: Re: [PATCH v2 03/34] sequencer (rebase -i): implement the 'edit' command

From: Junio C Hamano <[email-masked]>
Date: Mon, 19 Dec 2016 10:48:36 -0800

Johannes Schindelin <[email-masked]> writes:

>> > +	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)) {
>> > +		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;
>> > +}
>> 
>> OK.  This seems to match what scripted make_patch does in a handful
>> of lines.  We probably should have given you a helper to reduce
>> boilerplate that sets up log_tree_opt so that this function does not
>> have to be this long, but that is a separate topic.
>> 
>> Does it matter output_format is set to FORMAT_PATCH here, though?
>> With --no-commit-id set, I suspect there is no log message or
>> authorship information given to the output.

Sorry, this was me being stupid.  

FORMAT_PATCH here does not have anythning to do with "git
format-patch" (and "git log --pretty=email").  The PATCH there is as
opposed to things like --stat and --raw.  We want patch text that
can be fed to "git apply" and it is absolutely the right thing to
use here.