rerere forget: grok files containing NUL
Using 'git rerere forget .' after a merge that involved binary files runs into an infinite loop if the binary file contains a zero byte. Replace a strchrnul by memchr because the former does not make progress as soon as the NUL is encountered. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
15999998fb
commit
53d8afafbb
6
rerere.c
6
rerere.c
@ -284,8 +284,10 @@ static int rerere_mem_getline(struct strbuf *sb, struct rerere_io *io_)
|
||||
strbuf_release(sb);
|
||||
if (!io->input.len)
|
||||
return -1;
|
||||
ep = strchrnul(io->input.buf, '\n');
|
||||
if (*ep == '\n')
|
||||
ep = memchr(io->input.buf, '\n', io->input.len);
|
||||
if (!ep)
|
||||
ep = io->input.buf + io->input.len;
|
||||
else if (*ep == '\n')
|
||||
ep++;
|
||||
len = ep - io->input.buf;
|
||||
strbuf_add(sb, io->input.buf, len);
|
||||
|
Reference in New Issue
Block a user