Code

for_each_recent_reflog_ent(): use strbuf, fix offset handling
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sat, 13 Mar 2010 17:37:50 +0000 (18:37 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 13 Mar 2010 21:18:09 +0000 (13:18 -0800)
commit8ca788035644f2aaf7a951272ae16a7bd319554c
tree0a9029d417f819d361294a1f2710a1a57ad99089
parent34b383e7cd57692fd3996c1e8c9e738dab53ac48
for_each_recent_reflog_ent(): use strbuf, fix offset handling

As Vladimir reported, "git log -g refs/stash" surprisingly showed the reflog
of HEAD if the message in the reflog file was too long.  To fix this, convert
for_each_recent_reflog_ent() to use strbuf_getwholeline() instead of fgets(),
for safety and to avoid any size limits for reflog entries.

Also reverse the logic of the part of the function that only looks at file
tails.  It used to close the file if fgets() succeeded.  The following
fgets() call in the while loop was likely to fail in this case, too, so
passing an offset to for_each_recent_reflog_ent() never worked.  Change it to
error out if strbuf_getwholeline() fails instead.

Reported-by: Vladimir Panteleev <vladimir@thecybershadow.net>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c