diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-10-14 16:16:33 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-10-21 15:57:17 -0700 |
commit | 4933910ab7a74ebcf13342726d7f055ee35a8f7c (patch) | |
tree | 5ae556a733f00e9d47eed4d914dc18ffe6ed0309 /builtin/mailinfo.c | |
parent | mailinfo: move content/content_top to struct mailinfo (diff) | |
download | tgif-4933910ab7a74ebcf13342726d7f055ee35a8f7c.tar.xz |
mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak
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>
Diffstat (limited to 'builtin/mailinfo.c')
-rw-r--r-- | builtin/mailinfo.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 93043255ad..4a8c704c8a 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -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')) |