Skip to content

Commit

Permalink
mailinfo: handle_commit_msg() shouldn't be called after finding patch…
Browse files Browse the repository at this point in the history
…break

There is a strange "if (!mi->cmitmsg) return 0" at the very beginning
of handle_commit_msg(), but the condition should never trigger, because:

 * The only place cmitmsg is set to NULL is after this function sees
   a patch break, closes the FILE * to write the commit log message
   and returns 1.  This function returns non-zero only from that
   codepath.

 * The caller of this function, upon seeing a non-zero return,
   increments filter_stage, starts treating the input as patch text
   and will never call handle_commit_msg() again.

Replace it with an assert(!mi->filter_stage) to ensure the above
observation will stay to be true.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Oct 21, 2015
1 parent 8e91927 commit 4933910
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions builtin/mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,7 @@ static int is_scissors_line(const struct strbuf *line)

static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
{
if (!mi->cmitmsg)
return 0;
assert(!mi->filter_stage);

if (mi->header_stage) {
if (!line->len || (line->len == 1 && line->buf[0] == '\n'))
Expand Down

0 comments on commit 4933910

Please sign in to comment.