[PATCH 18/26] mailinfo: handle_commit_msg() shouldn't be called after finding patchbreak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is a strange "if (!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).

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 builtin/mailinfo.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index a51b2c5..256d04a 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -731,8 +731,7 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
 	 */
 	int is_empty_line;
 
-	if (!cmitmsg)
-		return 0;
+	assert(!mi->filter_stage);
 
 	is_empty_line = (!line->len || (line->len == 1 && line->buf[0] == '\n'));
 	if (mi->header_stage == 1) {
-- 
2.6.1-320-g86a1181

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]